On 01/22/15 11:03, Luis Felipe Strano Moraes wrote: > toys/lsb/mktemp.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/toys/lsb/mktemp.c b/toys/lsb/mktemp.c > index c1175fe..e76bff4 100644 > --- a/toys/lsb/mktemp.c > +++ b/toys/lsb/mktemp.c > @@ -37,6 +37,7 @@ void mktemp_main(void) > if (!tmp) { > if (!TT.tmpdir) TT.tmpdir = "/tmp"; > tmp = "tmp.xxxxxx"; > + xputs("OLA toys.optargs tava vazio"); > } > if (TT.tmpdir) tmp = xmprintf("%s/%s", TT.tmpdir ? TT.tmpdir : "/tmp", > *toys.optargs ? *toys.optargs : "tmp.XXXXXX"); > @@ -47,6 +48,4 @@ void mktemp_main(void) > d_flag ? "directory" : "file"); > > xputs(tmp); > - > - if (CFG_TOYBOX_FREE && TT.tmpdir) free(tmp); > }
I'm guessing the xputs() is a leftover debugging thing? (mktemp outputs the name of the temporary directory and nothing else, that's so it's scriptable.) xmprintf() is in lib/xwrap.c, it mallocs the string it returns. The free is cleaning up after that. I'm guessing your static analysis thing had a similar "may be used uninitialized" problem because the test for whether or not we free the variable (if (TT.tmpdir)) is a different variable with a different lifetime from the variable we're freeing. So sometimes tmp has heap data and sometimes it has non-heap data, but the test should correctly distinguish between them in a way that the static analysis doesn't get. Not applying this one. Rob _______________________________________________ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net