lkml.org 
[lkml]   [2012]   [Sep]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3 8/9] perf hists browser: Add option for runtime switching perf data file
On Tue, 25 Sep 2012 11:11:21 +0900
Namhyung Kim <namhyung@kernel.org> wrote:

> On Mon, 24 Sep 2012 23:24:10 +0800, Feng Tang wrote:
> [snip]
> > + if (!check_perf_magic(magic)) {
> > + options[nr_options] = strdup(name);
> > + abs_path[nr_options++] = strdup(path);
>
> Need to check return values.
>
>
> > + }
> > + fclose(file);
> > + }
> > + closedir(pwd_dir);
> > +
> > + if (nr_options) {
> > + choice = ui__popup_menu(nr_options, options);
> > + if (choice < nr_options && choice >= 0) {
> > + input_name = strdup(abs_path[choice]);
>
> Ditto. Plus it might leak previous input_name.

Nice catch, will check the return value of "strdup".

For input_name mem leak, in some cases the input_name can't be called
with free(), like those got from parse "-i" option. In case the old
input_name is got from malloc through strdup, I think it's not a big
issue given that buffer will be freed any way when the application exit.

Thanks,
Feng

>
> Thanks,
> Namhyung
>
>
> > + ret = 0;
> > + }
> > + }
> > +
> > + free_popup_options(options, nr_options);
> > + free_popup_options(abs_path, nr_options);
> > + return ret;
> > +}
> > +
> > +


\
 
 \ /
  Last update: 2012-09-25 11:01    [W:1.325 / U:0.228 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site