add missing null pointer checks (#80)

The result of copying a null pointer is undefined.
This commit is contained in:
Vlad-Ștefan Harbuz 2023-05-29 20:36:32 +01:00 committed by GitHub
parent d4c94500c4
commit 52e9c039c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

4
toml.c
View file

@ -412,8 +412,10 @@ static void *expand(void *p, int sz, int newsz) {
if (!s)
return 0;
if (p) {
memcpy(s, p, sz);
FREE(p);
}
return s;
}
@ -423,8 +425,10 @@ static void **expand_ptrarr(void **p, int n) {
return 0;
s[n] = 0;
if (p) {
memcpy(s, p, n * sizeof(void *));
FREE(p);
}
return s;
}