summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-05-08 20:24:11 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-05-08 20:24:11 -0500
commit12ecdf5c20fcfc0ab7f597e9ebe2ce1f9bf63b1a (patch)
treed2951c7806d164eb42eb51ed1eac63502e2ab683
parentee849d022bea6bcf7fa2f7747b993034b16096fa (diff)
downloadgcompat-12ecdf5c20fcfc0ab7f597e9ebe2ce1f9bf63b1a.tar.gz
gcompat-12ecdf5c20fcfc0ab7f597e9ebe2ce1f9bf63b1a.tar.bz2
gcompat-12ecdf5c20fcfc0ab7f597e9ebe2ce1f9bf63b1a.tar.xz
gcompat-12ecdf5c20fcfc0ab7f597e9ebe2ce1f9bf63b1a.zip
string: check NULL before using src here, too
-rw-r--r--libgcompat/malloc.c2
-rw-r--r--libgcompat/string.c3
2 files changed, 3 insertions, 2 deletions
diff --git a/libgcompat/malloc.c b/libgcompat/malloc.c
index 3f54a06..5a82bc4 100644
--- a/libgcompat/malloc.c
+++ b/libgcompat/malloc.c
@@ -64,7 +64,7 @@ alias(__libc_malloc, __malloc);
void *__libc_memalign(size_t align, size_t len)
{
- void *result;
+ void *result = NULL;
if (posix_memalign(&result, align, len) != 0)
return NULL;
return result;
diff --git a/libgcompat/string.c b/libgcompat/string.c
index f96e8d6..1b3673b 100644
--- a/libgcompat/string.c
+++ b/libgcompat/string.c
@@ -167,10 +167,11 @@ char *__strcat_chk(char *dest, const char *src, size_t destlen)
*/
char *__strcpy_chk(char *dest, const char *src, size_t destlen)
{
- size_t n = strlen(src) + 1;
+ size_t n;
assert(dest != NULL);
assert(src != NULL);
+ n = strlen(src) + 1;
assert(destlen >= n);
if (dest < src) {
assert(dest + n <= src);