1.1 --- a/src/string.c Tue Jan 02 17:00:21 2018 +0100 1.2 +++ b/src/string.c Sun Jan 21 10:13:21 2018 +0100 1.3 @@ -269,14 +269,18 @@ 1.4 } else /* no match possible */ { 1.5 *n = 1; 1.6 sstr_t *result = (sstr_t*) almalloc(allocator, sizeof(sstr_t)); 1.7 - *result = sstrdup_a(allocator, s); 1.8 + if(result) { 1.9 + *result = sstrdup_a(allocator, s); 1.10 + } else { 1.11 + *n = -2; 1.12 + } 1.13 return result; 1.14 } 1.15 } 1.16 1.17 ssize_t nmax = *n; 1.18 size_t arrlen = 16; 1.19 - sstr_t* result = (sstr_t*) almalloc(allocator, arrlen*sizeof(sstr_t)); 1.20 + sstr_t* result = (sstr_t*) alcalloc(allocator, arrlen, sizeof(sstr_t)); 1.21 1.22 if (result) { 1.23 sstr_t curpos = s; 1.24 @@ -310,8 +314,12 @@ 1.25 j++; 1.26 if (j > arrlen) { 1.27 arrlen *= 2; 1.28 - sstr_t* reallocated = (sstr_t*) alrealloc( 1.29 - allocator, result, arrlen*sizeof(sstr_t)); 1.30 + size_t reallocsz; 1.31 + sstr_t* reallocated = NULL; 1.32 + if(!ucx_szmul(arrlen, sizeof(sstr_t), &reallocsz)) { 1.33 + reallocated = (sstr_t*) alrealloc( 1.34 + allocator, result, reallocsz); 1.35 + } 1.36 if (reallocated) { 1.37 result = reallocated; 1.38 } else {