Hi there, I am trying to use splint with a program of mine that uses libcurl. Stripped to the bone, my program looks like this:
#include <curl/curl.h> int main() { CURL *c = curl_easy_init(); FILE *out = fopen("/tmp/junk", "w"); if (out == NULL) exit(EXIT_FAILURE); curl_easy_reset(c); (void)curl_easy_setopt(c, CURLOPT_URL, "http://google.com"); (void)curl_easy_setopt(c, CURLOPT_HEADER, 1); (void)curl_easy_setopt(c, CURLOPT_WRITEDATA, out); (void)curl_easy_perform(c); curl_easy_cleanup(c); (void)fclose(out); return 0; } splint gives me a warning about a memory leak detected at line 16: Splint 3.1.2 --- 03 May 2009 Spec file not found: c.lcl c.c: (in function main) c.c:16:14: Fresh storage c not released before return A memory leak has been detected. Storage allocated locally is not released before the last reference to it is lost. (Use -mustfreefresh to inhibit warning) c.c:5:32: Fresh storage c created Finished checking --- 1 code warning Clearly, this is because splint does not know that `curl_easy_cleanup` frees the memory allocated with `curl_easy_init`. Usually, when I have control over allocation/deallocation I can annotate constructors and destructors properly, but in this case allocation/deallocation happens in an external library, and functions prototypes are defined in a header fil <curl/curl.h> that I can't modify. So, how do I instruct splint that `curl_easy_cleanup` frees `*c` without touching <curl/curl.h>? Thanks, L.
_______________________________________________ splint-discuss mailing list splint-discuss@mail.cs.virginia.edu http://www.cs.virginia.edu/mailman/listinfo/splint-discuss