48 lines
1.3 KiB
Diff
48 lines
1.3 KiB
Diff
From 72c95ff9a6aadf787d798deb47ec125e6a2ed8cc Mon Sep 17 00:00:00 2001
|
|
From: Jardel Weyrich <jweyrich@gmail.com>
|
|
Date: Tue, 18 Jul 2017 15:23:24 -0300
|
|
Subject: [PATCH 09/12] Fix memory leak during output scope unwinding.
|
|
|
|
---
|
|
include/output.h | 2 +-
|
|
src/output.c | 3 ++-
|
|
2 files changed, 3 insertions(+), 2 deletions(-)
|
|
|
|
diff --git include/output.h include/output.h
|
|
index 48e843e..7877454 100644
|
|
--- include/output.h
|
|
+++ include/output.h
|
|
@@ -59,7 +59,7 @@ typedef enum {
|
|
} output_scope_type_e;
|
|
|
|
typedef struct {
|
|
- const char *name;
|
|
+ char *name;
|
|
output_scope_type_e type;
|
|
uint16_t depth;
|
|
output_scope_type_e parent_type;
|
|
diff --git src/output.c src/output.c
|
|
index 8c23e92..8ac837f 100644
|
|
--- src/output.c
|
|
+++ src/output.c
|
|
@@ -305,7 +305,7 @@ void output_open_scope(const char *scope_name, output_scope_type_e scope_type) {
|
|
void output_close_scope(void) {
|
|
assert(g_format != NULL);
|
|
|
|
- output_scope_t * const scope = NULL;
|
|
+ output_scope_t *scope = NULL;
|
|
int ret = STACK_POP(g_scope_stack, (void *)&scope);
|
|
if (ret < 0) {
|
|
fprintf(stderr, "output: cannot close a scope that has not been opened.\n");
|
|
@@ -320,6 +320,7 @@ void output_close_scope(void) {
|
|
if (g_format != NULL)
|
|
g_format->output_fn(g_format, type, scope, key, value);
|
|
|
|
+ free(scope->name);
|
|
free(scope);
|
|
}
|
|
|
|
--
|
|
2.26.2.672.g232c24e857
|
|
|