nqminds / edgesec

Secure router - reference implementation
https://edgesec.info
MIT License
6 stars 1 forks source link

test(runctl): fix `test_init_context()` memory leak #524

Closed aloisklink closed 1 year ago

aloisklink commented 1 year ago

test_init_context() in test/test_runctl.c creates ctx->config_ifinfo_array, but it's never deallocated.

In fact, it's even allocated twice to the same variable.

Allocated here:

I've removed the extraneous allocation, and added a utarray_free(context.config_ifinfo_array); at the end of the test function to fix this memory leak.


Side-note, the cleanup code for a struct supervisor_context and struct app_config is currently a bit messy. Can we somehow refactor this into cleanup functions?

codecov[bot] commented 1 year ago

Codecov Report

Merging #524 (e940f3a) into main (8e2f61a) will decrease coverage by 0.01%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #524      +/-   ##
==========================================
- Coverage   53.57%   53.56%   -0.01%     
==========================================
  Files         144      144              
  Lines       20005    20001       -4     
==========================================
- Hits        10717    10713       -4     
  Misses       9288     9288              
Impacted Files Coverage Δ
tests/test_runctl.c 94.73% <100.00%> (-0.18%) :arrow_down:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

mereacre commented 1 year ago

Feel free to add PR for cleanup.