From dcf8ad365e51bd44ccb38fac72c4764dc9996f20 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Thu, 31 Jul 2014 16:32:50 -0600 Subject: [PATCH] Coverity: 711838 --- libdispatch/ncaux.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libdispatch/ncaux.c b/libdispatch/ncaux.c index 046f22cb4..5571c268a 100644 --- a/libdispatch/ncaux.c +++ b/libdispatch/ncaux.c @@ -72,8 +72,11 @@ ncaux_begin_compound(int ncid, const char *name, int alignmode, void** tagp) cmpd->name = strdup(name); if(cmpd->name == NULL) {status = NC_ENOMEM; goto fail;} - if(tagp) *tagp = (void*)cmpd; - + if(tagp) { + *tagp = (void*)cmpd; + } else { /* Error, free cmpd to avoid memory leak. */ + free(cmpd); + } return status; fail: