add missing null pointer checks (#80)
The result of copying a null pointer is undefined.
This commit is contained in:
parent
d4c94500c4
commit
52e9c039c5
1 changed files with 8 additions and 4 deletions
4
toml.c
4
toml.c
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue