diff options
| author | Donald Sharp <donaldsharp72@gmail.com> | 2023-05-09 13:31:10 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-09 13:31:10 -0400 |
| commit | 183dabba65ec90ebcc1a367a20bb7376a34f8e02 (patch) | |
| tree | 690817e68be6eeabe93a357ce9edafa14ab0307c | |
| parent | cc0a43da5a1a4e87964dbe08ca07bac34a2ffa7b (diff) | |
| parent | a49643612006672a03de4c0b13fa4298dc3f58de (diff) | |
Merge pull request #13482 from FRRouting/mergify/bp/stable/8.4/pr-13445
zebra: Reduce creation and fix memory leak of frrscripting pointers (backport #13445)
| -rw-r--r-- | zebra/zebra_rib.c | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 08391f1a3d..171837610a 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -4587,6 +4587,21 @@ static void rib_process_dplane_results(struct thread *thread) struct dplane_ctx_q ctxlist; bool shut_p = false; +#ifdef HAVE_SCRIPTING + char *script_name = + frrscript_names_get_script_name(ZEBRA_ON_RIB_PROCESS_HOOK_CALL); + + int ret = 1; + struct frrscript *fs = NULL; + + if (script_name) { + fs = frrscript_new(script_name); + if (fs) + ret = frrscript_load(fs, ZEBRA_ON_RIB_PROCESS_HOOK_CALL, + NULL); + } +#endif /* HAVE_SCRIPTING */ + /* Dequeue a list of completed updates with one lock/unlock cycle */ do { @@ -4620,24 +4635,7 @@ static void rib_process_dplane_results(struct thread *thread) continue; } -#ifdef HAVE_SCRIPTING - char *script_name = frrscript_names_get_script_name( - ZEBRA_ON_RIB_PROCESS_HOOK_CALL); - - int ret = 1; - struct frrscript *fs; - - if (script_name) { - fs = frrscript_new(script_name); - if (fs) - ret = frrscript_load( - fs, ZEBRA_ON_RIB_PROCESS_HOOK_CALL, - NULL); - } -#endif /* HAVE_SCRIPTING */ - while (ctx) { - #ifdef HAVE_SCRIPTING if (ret == 0) frrscript_call(fs, @@ -4747,6 +4745,11 @@ static void rib_process_dplane_results(struct thread *thread) } } while (1); + +#ifdef HAVE_SCRIPTING + if (fs) + frrscript_delete(fs); +#endif } /* |
