]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-11442 [test] Fix double-free on test suite cleanup.
authorChris Rienzo <chris@signalwire.com>
Fri, 26 Oct 2018 17:26:33 +0000 (13:26 -0400)
committerChris Rienzo <chris@signalwire.com>
Thu, 20 Dec 2018 15:19:02 +0000 (10:19 -0500)
src/include/test/switch_fct.h

index e85f7865ef4c66846cf1c93b5bb08abd821165be..8cd01cb77a15f207607c95634b4dfbf516727a79 100644 (file)
@@ -2695,11 +2695,13 @@ fct_logger__on_warn(fct_logger_i *logger, char const *msg)
 
 /* Common routine to record strings representing failures. The
 chk should be a failure before we call this, and the list is a list
-of char*'s that will eventually be free'd by the logger. */
+of conditions that will eventually be free'd by the logger. */
 static void
 fct_logger_record_failure(fctchk_t const* chk, fct_nlist_t* fail_list)
 {
-    fct_nlist__append(fail_list, (void *)chk);
+    fctchk_t *dup_chk = (fctchk_t *)malloc(sizeof(*dup_chk));
+    memcpy(dup_chk, chk, sizeof(*dup_chk));
+    fct_nlist__append(fail_list, (void *)dup_chk);
 }
 
 
@@ -2795,7 +2797,7 @@ fct_minimal_logger__on_delete(
 {
     fct_minimal_logger_t *self = (fct_minimal_logger_t*)self_;
     fct_unused(e);
-    fct_nlist__final(&(self->failed_cndtns_list), free);
+    fct_nlist__final(&(self->failed_cndtns_list), (fct_nlist_on_del_t)fctchk__del);
     free(self);
 
 }
@@ -2966,7 +2968,7 @@ fct_standard_logger__on_delete(
 {
     fct_standard_logger_t *logger = (fct_standard_logger_t*)logger_;
     fct_unused(e);
-    fct_nlist__final(&(logger->failed_cndtns_list), free);
+    fct_nlist__final(&(logger->failed_cndtns_list), (fct_nlist_on_del_t)fctchk__del);
     free(logger);
     logger_ =NULL;
 }