diff options
| author | Xavier Del Campo Romero <xavier.delcampo@orain.io> | 2020-03-25 10:48:54 +0100 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavier.delcampo@orain.io> | 2020-03-25 10:48:54 +0100 |
| commit | 357d4f2c0fc52ae7e5967f542161d59d09830e27 (patch) | |
| tree | 81da58b7f1bcc2f96222c76e982d1901b1610cc6 | |
| parent | 46d7c1715b9b710e5afc9a259f7d7c48ce7bcb01 (diff) | |
| download | dynstr-357d4f2c0fc52ae7e5967f542161d59d09830e27.tar.gz | |
Avoid free() if no string is present
| -rw-r--r-- | dynstr.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -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); + } } |
