Message ID | 20190612182019.169932649@goodmis.org (mailing list archive) |
---|---|
State | Accepted |
Commit | 7cf07883112fc1e3325addccf9127a815a2786ee |
Headers | show |
Series | trace-cmd: Fix some bugs that include issues with --max-graph-depth | expand |
On Wed, Jun 12, 2019 at 9:19 PM Steven Rostedt <rostedt@goodmis.org> wrote: > > From: "Steven Rostedt (VMware)" <rostedt@goodmis.org> > > If get_file_content() returns NULL, because the file does not exist or for > any other reason, it will cause add_reset_file() to trigger a SEGSEGV due to > using a NULL pointer. Only call add_reset_file() if get_file_content() > actually returns something. > > Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org> > --- Looks OK. Reviewed-by: Tzvetomir Stoyanov <tstoyanov@vmware.com> > tracecmd/trace-record.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c > index 2d716a81acbf..5dc6f17aa743 100644 > --- a/tracecmd/trace-record.c > +++ b/tracecmd/trace-record.c > @@ -270,8 +270,10 @@ static void reset_save_file(const char *file, int prio) > char *content; > > content = get_file_content(file); > - add_reset_file(file, content, prio); > - free(content); > + if (content) { > + add_reset_file(file, content, prio); > + free(content); > + } > } > > /* > -- > 2.20.1 > > -- Tzvetomir (Ceco) Stoyanov VMware Open Source Technology Center
diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c index 2d716a81acbf..5dc6f17aa743 100644 --- a/tracecmd/trace-record.c +++ b/tracecmd/trace-record.c @@ -270,8 +270,10 @@ static void reset_save_file(const char *file, int prio) char *content; content = get_file_content(file); - add_reset_file(file, content, prio); - free(content); + if (content) { + add_reset_file(file, content, prio); + free(content); + } } /*