From: Mark Andrews Date: Wed, 4 Sep 2019 01:27:16 +0000 (+1000) Subject: address NULL pointer dereferences X-Git-Tag: v9.15.4~11^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2de94dd4c4ee170b071dd9c61cb10f3aedaa4485;p=thirdparty%2Fbind9.git address NULL pointer dereferences --- diff --git a/contrib/dlz/modules/mysqldyn/dlz_mysqldyn_mod.c b/contrib/dlz/modules/mysqldyn/dlz_mysqldyn_mod.c index 577ae65a426..f8e47f8f24c 100644 --- a/contrib/dlz/modules/mysqldyn/dlz_mysqldyn_mod.c +++ b/contrib/dlz/modules/mysqldyn/dlz_mysqldyn_mod.c @@ -1297,9 +1297,21 @@ dlz_newversion(const char *zone, void *dbdata, void **versionp) { * Create new transaction */ newtx = (mysql_transaction_t *) - malloc(sizeof(mysql_transaction_t)); + calloc(1, sizeof(mysql_transaction_t)); + if (newtx == NULL) { + result = ISC_R_NOMEMORY; + goto cleanup; + } newtx->zone = strdup(zone); + if (newtx->zone == NULL) { + result = ISC_R_NOMEMORY; + goto cleanup; + } newtx->zone_id = strdup(zone_id); + if (newtx->zone_id == NULL) { + result = ISC_R_NOMEMORY; + goto cleanup; + } newtx->dbi = get_dbi(state); newtx->next = NULL; @@ -1329,9 +1341,15 @@ dlz_newversion(const char *zone, void *dbdata, void **versionp) { *versionp = (void *) newtx; } else { dlz_mutex_unlock(&state->tx_mutex); - free(newtx->zone); - free(newtx->zone_id); - free(newtx); + if (newtx != NULL) { + if (newtx->zone != NULL) { + free(newtx->zone); + } + if (newtx->zone != NULL) { + free(newtx->zone_id); + } + free(newtx); + } } return (result);