Browse Source

Memory leak fixes

Yann Weber 7 years ago
parent
commit
cacdfc3534
2 changed files with 7 additions and 1 deletions
  1. 6
    0
      src/ttail_init.c
  2. 1
    1
      tests/ttail_search_check.c

+ 6
- 0
src/ttail_init.c View File

@@ -392,6 +392,10 @@ for date format");
392 392
 void ttail_free(ttail_t* t)
393 393
 {
394 394
 	size_t i;
395
+	if(t->flag & TTAIL_FLAG_PREFIX && t->prefix_sz < 0)
396
+	{
397
+		regfree(&(t->date_prefix));
398
+	}
395 399
 	for(i=0; i<t->logfile_sz; i++)
396 400
 	{
397 401
 		if(t->logfile[i])
@@ -403,6 +407,8 @@ void ttail_free(ttail_t* t)
403 407
 			free(t->logfile_name[i]);
404 408
 		}
405 409
 	}
410
+	free(t->logfile);
411
+	free(t->logfile_name);
406 412
 	t->logfile_sz = 0;
407 413
 	if(t->fmt != NULL)
408 414
 	{

+ 1
- 1
tests/ttail_search_check.c View File

@@ -51,8 +51,8 @@ void setup_closest_fileinit(void)
51 51
 
52 52
 void teardown_closest_fileinit(void)
53 53
 {
54
-	teardown_closest();
55 54
 	_ttail_search_file_free(ttail);
55
+	teardown_closest();
56 56
 }
57 57
 
58 58
 START_TEST (test_search_closest_init)

Loading…
Cancel
Save