* 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;
*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);