From: Julien Desfossez Date: Wed, 12 Feb 2014 05:28:15 +0000 (-0500) Subject: Free the filename on sys_close X-Git-Tag: v0.3~34 X-Git-Url: http://git.lttng.org/?p=lttngtop.git;a=commitdiff_plain;h=38be0c3fdc487f3cc2609266a33a39b96289faba;ds=sidebyside Free the filename on sys_close We don't support yet all the syscalls that can return a FD, so we should at least make sure that we don't reuse closed filenames. Signed-off-by: Julien Desfossez --- diff --git a/src/iostreamtop.c b/src/iostreamtop.c index f20fcec..f3fef7b 100644 --- a/src/iostreamtop.c +++ b/src/iostreamtop.c @@ -48,7 +48,8 @@ void add_file(struct processtop *proc, struct files *file, int fd) if (tmp_file == NULL) g_ptr_array_index(proc->process_files_table, fd) = file; else { - if (strcmp(tmp_file->name, file->name) != 0) { + if (!tmp_file->name || + strcmp(tmp_file->name, file->name) != 0) { size = proc->process_files_table->len; g_ptr_array_set_size(proc->process_files_table, size+1); @@ -139,6 +140,10 @@ void close_file(struct processtop *proc, int fd) if (file != NULL) { file->flag = __NR_close; lttngtop.nbfiles--; + if (file->name) { + free(file->name); + file->name = NULL; + } } lttngtop.nbclosedfiles++; }