Message ID | 20200824093057.63672-1-colin.king@canonical.com |
---|---|
State | Accepted |
Headers | show |
Series | lib: fwts_log_json: fix memory leak | expand |
On 2020-08-24 3:30 a.m., Colin King wrote: > From: Colin Ian King <colin.king@canonical.com> > > The string str is not being free'd after use, leading to a memory > leak. Free it. > > Signed-off-by: Colin Ian King <colin.king@canonical.com> > --- > src/lib/src/fwts_log_json.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/src/lib/src/fwts_log_json.c b/src/lib/src/fwts_log_json.c > index 1a917e63..7bb5110a 100644 > --- a/src/lib/src/fwts_log_json.c > +++ b/src/lib/src/fwts_log_json.c > @@ -211,7 +211,7 @@ static void fwts_log_open_json(fwts_log_file *log_file) > > static void fwts_log_close_json(fwts_log_file *log_file) > { > - const char *str; > + char *str; > > fwts_log_section_end_json(log_file); > > @@ -233,6 +233,7 @@ static void fwts_log_close_json(fwts_log_file *log_file) > log_file->line_number++; > } > json_object_put(json_stack[0].obj); > + free(str); > } > > fwts_log_ops fwts_log_json_ops = { > Acked-by: Alex Hung <alex.hung@canonical.com>
On 8/24/20 5:30 PM, Colin King wrote: > From: Colin Ian King <colin.king@canonical.com> > > The string str is not being free'd after use, leading to a memory > leak. Free it. > > Signed-off-by: Colin Ian King <colin.king@canonical.com> > --- > src/lib/src/fwts_log_json.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/src/lib/src/fwts_log_json.c b/src/lib/src/fwts_log_json.c > index 1a917e63..7bb5110a 100644 > --- a/src/lib/src/fwts_log_json.c > +++ b/src/lib/src/fwts_log_json.c > @@ -211,7 +211,7 @@ static void fwts_log_open_json(fwts_log_file *log_file) > > static void fwts_log_close_json(fwts_log_file *log_file) > { > - const char *str; > + char *str; > > fwts_log_section_end_json(log_file); > > @@ -233,6 +233,7 @@ static void fwts_log_close_json(fwts_log_file *log_file) > log_file->line_number++; > } > json_object_put(json_stack[0].obj); > + free(str); > } > > fwts_log_ops fwts_log_json_ops = { > Acked-by: Ivan Hu <ivan.hu@canonical.com>
diff --git a/src/lib/src/fwts_log_json.c b/src/lib/src/fwts_log_json.c index 1a917e63..7bb5110a 100644 --- a/src/lib/src/fwts_log_json.c +++ b/src/lib/src/fwts_log_json.c @@ -211,7 +211,7 @@ static void fwts_log_open_json(fwts_log_file *log_file) static void fwts_log_close_json(fwts_log_file *log_file) { - const char *str; + char *str; fwts_log_section_end_json(log_file); @@ -233,6 +233,7 @@ static void fwts_log_close_json(fwts_log_file *log_file) log_file->line_number++; } json_object_put(json_stack[0].obj); + free(str); } fwts_log_ops fwts_log_json_ops = {