aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dynstr.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/dynstr.c b/dynstr.c
index 025f1fc..f816155 100644
--- a/dynstr.c
+++ b/dynstr.c
@@ -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);
+ }
}