diff --git a/src/mdata.c b/src/mdata.c index f36e6e6..403097b 100644 --- a/src/mdata.c +++ b/src/mdata.c @@ -277,7 +277,8 @@ mdata_destroy(struct mdata **md_p) { struct mdata *md = *md_p; - _mdata_clear(md); + if (md) + _mdata_clear(md); xfree(md); *md_p = NULL; } diff --git a/tests/check_mdata.c b/tests/check_mdata.c index bd5f4aa..ac06501 100644 --- a/tests/check_mdata.c +++ b/tests/check_mdata.c @@ -193,6 +193,7 @@ setup_checked(void) void teardown_checked(void) { + mdata_destroy(&md); mdata_destroy(&md); ck_assert_ptr_eq(md, NULL);