Author: minfrin
Date: Tue Mar 11 17:55:34 2025
New Revision: 1924307
URL: http://svn.apache.org/viewvc?rev=1924307&view=rev
Log:
Backport r1920246:
testmmap: Avoid a crash after test_file_open() fails.
Modified:
apr/apr/branches/1.8.x/CHANGES
apr/apr/branches/1.8.x/test/testmmap.c
Modified: apr/apr/branches/1.8.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.8.x/CHANGES?rev=1924307&r1=1924306&r2=1924307&view=diff
==============================================================================
--- apr/apr/branches/1.8.x/CHANGES [utf-8] (original)
+++ apr/apr/branches/1.8.x/CHANGES [utf-8] Tue Mar 11 17:55:34 2025
@@ -1,6 +1,9 @@
-*- coding: utf-8 -*-
Changes for APR 1.8.0
+ *) testmmap: Avoid a crash after test_file_open() fails. [Graham
+ Leggett]
+
*) apr_proc_mutex_timedlock() should return APR_TIMEUP on systems
where semtimedop() returns ETIMEDOUT rather than
EAGAIN. Likely AIX-only. [Eric Covener]
Modified: apr/apr/branches/1.8.x/test/testmmap.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.8.x/test/testmmap.c?rev=1924307&r1=1924306&r2=1924307&view=diff
==============================================================================
--- apr/apr/branches/1.8.x/test/testmmap.c (original)
+++ apr/apr/branches/1.8.x/test/testmmap.c Tue Mar 11 17:55:34 2025
@@ -77,6 +77,11 @@ static void test_file_close(abts_case *t
{
apr_status_t rv;
+ if (!thefile) {
+ ABTS_SKIP(tc, data, "File not open, skipping file close.");
+ return;
+ }
+
rv = apr_file_close(thefile);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
thefile = NULL;
@@ -96,6 +101,11 @@ static void test_get_filesize(abts_case
{
apr_status_t rv;
+ if (!thefile) {
+ ABTS_SKIP(tc, data, "File not open, skipping filesize test.");
+ return;
+ }
+
rv = apr_file_info_get(&thisfinfo, APR_FINFO_NORM, thefile);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
ABTS_TRUE(tc, thisfinfo.size == (apr_off_t)(apr_size_t)thisfinfo.size);
@@ -111,6 +121,11 @@ static void read_expected_contents(abts_
apr_size_t nbytes = 0;
apr_status_t rv;
+ if (!thefile) {
+ ABTS_SKIP(tc, data, "File not open, skipping read.");
+ return;
+ }
+
ABTS_TRUE(tc, *offset == (apr_off_t)(apr_size_t)*offset);
rv = apr_file_read_full(thefile, thisfdata, thisfsize, &nbytes);
@@ -135,6 +150,11 @@ static void test_mmap_create(abts_case *
apr_off_t *offset = data;
apr_status_t rv;
+ if (!thefile) {
+ ABTS_SKIP(tc, data, "File not open, skipping mmap create.");
+ return;
+ }
+
rv = apr_mmap_create(&themmap, thefile, *offset, thisfsize,
APR_MMAP_READ, ptest);
ABTS_PTR_NOTNULL(tc, themmap);
@@ -144,21 +164,33 @@ static void test_mmap_create(abts_case *
static void test_mmap_contents(abts_case *tc, void *data)
{
ABTS_PTR_NOTNULL(tc, themmap);
+
+ if (!themmap) {
+ ABTS_SKIP(tc, data, "MMap not open, skipping size comparison.");
+ return;
+ }
+
ABTS_PTR_NOTNULL(tc, themmap->mm);
ABTS_SIZE_EQUAL(tc, thisfsize, themmap->size);
/* Must use nEquals since the string is not guaranteed to be NULL terminated */
ABTS_STR_NEQUAL(tc, themmap->mm, thisfdata, thisfsize);
+
}
static void test_mmap_delete(abts_case *tc, void *data)
{
apr_status_t rv;
- ABTS_PTR_NOTNULL(tc, themmap);
+ if (!themmap) {
+ ABTS_SKIP(tc, data, "MMap not open, skipping mmap delete.");
+ return;
+ }
+
rv = apr_mmap_delete(themmap);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
themmap = NULL;
+
}
static void test_mmap_offset(abts_case *tc, void *data)
@@ -166,12 +198,17 @@ static void test_mmap_offset(abts_case *
apr_status_t rv;
void *addr;
- ABTS_PTR_NOTNULL(tc, themmap);
+ if (!themmap) {
+ ABTS_SKIP(tc, data, "MMap not open, skipping mmap offset.");
+ return;
+ }
+
rv = apr_mmap_offset(&addr, themmap, 5);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
/* Must use nEquals since the string is not guaranteed to be NULL terminated */
ABTS_STR_NEQUAL(tc, addr, thisfdata + 5, thisfsize - 5);
+
}
#endif
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.