On Wed, Feb 22, 2012 at 2:18 AM, Wenzel, Bodo <wen...@bbr-vt.de> wrote: > @Michael: You are perfectly right. > > @Robert: Would you mind to tell us your version of Splint and the command > line you give it, please? > > This report: >> Kept storage min_string passed as only param: free (min_string) >> storage is transferred to a non-temporary reference after being passed as >> keep parameter. The storage may be released or new aliases created. (Use >> -kepttrans to inhibit warning) >> Storage min_string becomes kept > > is triggered by this erroneous source: >> options->min_string = min_string; >> >> free(min_string); > >> Dead storage options->low_charset passed as out parameter to free: > Well, sorry, my knowledge about Splint's memory model is quite limited. I > have no clue how to straighten this. The whole source looks overcomplicated > in my eyes. > >> if (options->startstring != NULL) >> for (i = 0; i < options->starthere; i++) >> min_string[i] = options->startstring[i]; > strncpy() could be the function of choice. > >> >> free(options->min_string); >> } >> >> int main(/*@ unused @*/ int argc, char **argv) { > Unless this is a test driver, you should check argc to ensure that argv[] > holds valid pointers. > >> options = calloc(200, sizeof(*options)); > Another candidate for malloc(). > >> options->clen = charset ? strlen(charset) : 0; > charset is already checked against NULL some lines above. > > For me Splint reported another: > > Kept storage charset passed as only param: free (charset) > Storage charset becomes kept > > So I changed > free(charset); > to > free(options->low_charset); > > Cheers, > Bodo
I am using the cvs version of splint that I downloaded about a month ago. I am using the cvs version as I was getting a lot of: Duplicate long qualifier on non-int messages from splint. Google shows a message from 2010 that says to use the cvs version as that fixes splint to handle unsigned long long. It has been almost 5 years since 3.1.2 was released maybe it is time to release 3.1.3??? I use sprint like this: splint program.c I compile with: gcc -g -o0 -Wall program.c -o program I run with: ./program 22 testing I use valgrind: valgrind --leak-check=yes ./program 22 testing Thanks, _______________________________________________ splint-discuss mailing list splint-discuss@mail.cs.virginia.edu http://www.cs.virginia.edu/mailman/listinfo/splint-discuss