From: Alan T. DeKok Date: Fri, 19 Nov 2021 15:38:26 +0000 (-0500) Subject: return the VP only if the allocate_update was successful X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8482c482331c4d06aa784d2c518a02df17a08973;p=thirdparty%2Ffreeradius-server.git return the VP only if the allocate_update was successful --- diff --git a/src/modules/rlm_sqlippool/rlm_sqlippool.c b/src/modules/rlm_sqlippool/rlm_sqlippool.c index 8486b3ab5b2..9bffb266acb 100644 --- a/src/modules/rlm_sqlippool/rlm_sqlippool.c +++ b/src/modules/rlm_sqlippool/rlm_sqlippool.c @@ -504,7 +504,7 @@ static unlang_action_t CC_HINT(nonnull) mod_alloc(rlm_rcode_t *p_result, module_ rlm_sqlippool_t *inst = talloc_get_type_abort(mctx->inst->data, rlm_sqlippool_t); char allocation[FR_MAX_STRING_LEN]; int allocation_len; - fr_pair_t *vp; + fr_pair_t *vp = NULL; rlm_sql_handle_t *handle; /* @@ -644,21 +644,22 @@ static unlang_action_t CC_HINT(nonnull) mod_alloc(rlm_rcode_t *p_result, module_ return do_logging(p_result, inst, request, inst->log_failed, RLM_MODULE_NOOP); } - RDEBUG2("Allocated IP %s", allocation); - fr_pair_append(&request->reply_pairs, vp); - /* * UPDATE */ if (sqlippool_command(inst->alloc_update, &handle, inst, request, allocation, allocation_len) < 0) { error: + talloc_free(vp); if (handle) fr_pool_connection_release(inst->sql_inst->pool, request, handle); RETURN_MODULE_FAIL; } DO_PART(alloc_commit); + RDEBUG2("Allocated IP %s", allocation); + fr_pair_append(&request->reply_pairs, vp); + if (handle) fr_pool_connection_release(inst->sql_inst->pool, request, handle); return do_logging(p_result, inst, request, inst->log_success, RLM_MODULE_OK);