]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Explicitly free rctx
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 30 Jan 2018 02:04:09 +0000 (19:04 -0700)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 30 Jan 2018 02:04:09 +0000 (19:04 -0700)
Else we'd leak memory into the REQUEST *

src/include/modules.h
src/main/module_unlang.c
src/modules/rlm_eap/rlm_eap.c

index d5f5a3545235b9314a8d5ebcea00cace6dcbf2d7..a42ca553fc8a8eaaaa966aacd08895fea5c64ed9 100644 (file)
@@ -309,12 +309,6 @@ int                unlang_event_timeout_delete(REQUEST *request, void const *ctx);
 
 int            unlang_event_fd_delete(REQUEST *request, void const *ctx, int fd);
 
-rlm_rcode_t    module_unlang_push_function(REQUEST *request,
-                                           unlang_function_t func,
-                                           unlang_function_t repeat,
-                                           fr_module_unlang_resume_t resume,
-                                           fr_module_unlang_signal_t signal, void *rctx);
-
 rlm_rcode_t    module_unlang_push_xlat(TALLOC_CTX *ctx, fr_value_box_t **out,
                                        REQUEST *request, xlat_exp_t const *xlat,
                                        fr_module_unlang_resume_t callback,
index d07b69d1584a52293e396f418733cd55f7dea31b..937dd836ac88ebdfc0a82f91cf28e5f8760a5953 100644 (file)
@@ -218,31 +218,6 @@ static unlang_action_t module_unlang_resume(REQUEST *request, rlm_rcode_t *presu
        }
 }
 
-/** Push a function onto the stack for execution and a resumption function to call after it completes
- *
- * @param[in] request          The current request.
- * @param[in] func             to call.
- * @param[in] resume           function to call when the function we pushed is complete.
- * @param[in] signal           function to call if a signal is received.
- * @param[in] rctx             to pass to the pushed function and resume()/signal() callbacks.
- * @return
- *     - RLM_MODULE_YIELD.
- */
-rlm_rcode_t module_unlang_push_function(REQUEST *request,
-                                       unlang_function_t func, unlang_function_t repeat,
-                                       fr_module_unlang_resume_t resume,
-                                       fr_module_unlang_signal_t signal, void *rctx)
-{
-       /*
-        *      Push the resumption point
-        */
-       (void) unlang_module_yield(request, resume, signal, rctx);
-
-       unlang_push_function(request, func, repeat, rctx);
-
-       return RLM_MODULE_YIELD;        /* This may allow us to do optimisations in future */
-}
-
 /** Push a pre-compiled xlat and resumption state onto the stack for evaluation
  *
  * In order to use the async unlang processor the calling module needs to establish
index cfd1c0c8895829db9738efebc59cf440c0042c83..059a0ad363bad41b0093913f936d708bc88cba9a 100644 (file)
@@ -343,7 +343,8 @@ static rlm_rcode_t mod_authenticate_result(REQUEST *request, void *instance, UNU
                eap_fail(eap_session);
                eap_session_destroy(&eap_session);
 
-               return RLM_MODULE_INVALID;
+               rcode = RLM_MODULE_INVALID;
+               goto finish;
        }
 
        /*
@@ -416,6 +417,8 @@ static rlm_rcode_t mod_authenticate_result(REQUEST *request, void *instance, UNU
         */
        eap_session_freeze(&eap_session);
 
+finish:
+       talloc_free(rctx);      /* Free rctx */
        return rcode;
 }
 
@@ -580,9 +583,14 @@ module_call:
        rctx->eap_session = eap_session;
        rctx->rcode = RLM_MODULE_UNKNOWN;
 
-       request->module = method->submodule->name;
-       return module_unlang_push_function(request, eap_call_submodule, eap_call_submodule,
-                                          mod_authenticate_result, NULL, rctx);
+       /*
+        *      mod_authenticate_result will be called after
+        *      eap_call_submodule finishes.
+        */
+       unlang_module_yield(request, mod_authenticate_result, NULL, rctx);
+       unlang_push_function(request, eap_call_submodule, eap_call_submodule, rctx);
+
+       return RLM_MODULE_YIELD;
 }
 
 static rlm_rcode_t mod_authenticate(void *instance, UNUSED void *thread, REQUEST *request)