Avoid free() if no string is present

This commit is contained in:
Xavier Del Campo Romero 2020-03-25 10:48:54 +01:00
parent 46d7c1715b
commit 357d4f2c0f
1 changed files with 5 additions and 2 deletions

View File

@ -89,6 +89,9 @@ enum dynstr_err dynstr_dup(struct dynstr *const dst, const struct dynstr *const
void dynstr_free(struct dynstr *const d)
{
free(d->str);
memset(d, 0, sizeof *d);
if (d->str)
{
free(d->str);
memset(d, 0, sizeof *d);
}
}