Merge topic 'cppcheck-fixes'

a20c819 cmake: Fix resource leak reported by cppcheck
c8adab9 cmcurl: Fix resource leak reported by cppcheck
499531c libarchive: Fix free() order to avoid accessing freed memory
3b849a7 ccmake: Add missing initializers reported by cppcheck
This commit is contained in:
Brad King 2013-07-16 13:59:30 -04:00 committed by CMake Topic Stage
commit ddfd3b85df
6 changed files with 12 additions and 6 deletions

View File

@ -30,7 +30,7 @@ static bool Check_IPV4_Field(FIELD * field, const void * argp)
{ {
char *bp = field_buffer(field,0); char *bp = field_buffer(field,0);
int num = 0, len; int num = 0, len;
unsigned int d1, d2, d3, d4; unsigned int d1=256, d2=256, d3=256, d4=256;
argp=0; /* Silence unused parameter warning. */ argp=0; /* Silence unused parameter warning. */

View File

@ -3667,11 +3667,11 @@ void cmake::RecordPropertyAccess(const char *name,
void cmake::ReportUndefinedPropertyAccesses(const char *filename) void cmake::ReportUndefinedPropertyAccesses(const char *filename)
{ {
if(!this->GlobalGenerator)
{ return; }
FILE *progFile = fopen(filename,"w"); FILE *progFile = fopen(filename,"w");
if (!progFile || !this->GlobalGenerator) if(!progFile)
{ { return; }
return;
}
// what are the enabled languages? // what are the enabled languages?
std::vector<std::string> enLangs; std::vector<std::string> enLangs;

View File

@ -56,6 +56,7 @@ int main(int argc, char **argv)
bodyfile = fopen(bodyfilename,"w"); bodyfile = fopen(bodyfilename,"w");
if (bodyfile == NULL) { if (bodyfile == NULL) {
curl_easy_cleanup(curl_handle); curl_easy_cleanup(curl_handle);
fclose(headerfile);
return -1; return -1;
} }
@ -70,6 +71,7 @@ int main(int argc, char **argv)
/* close the header file */ /* close the header file */
fclose(headerfile); fclose(headerfile);
fclose(bodyfile);
/* cleanup curl stuff */ /* cleanup curl stuff */
curl_easy_cleanup(curl_handle); curl_easy_cleanup(curl_handle);

View File

@ -114,5 +114,7 @@ int main(int argc, char **argv)
curl_global_cleanup(); curl_global_cleanup();
if (headerfile)
fclose(headerfile);
return 0; return 0;
} }

View File

@ -969,6 +969,8 @@ int Curl_cookie_output(struct CookieInfo *c, char *dumphere)
format_ptr = get_netscape_format(co); format_ptr = get_netscape_format(co);
if (format_ptr == NULL) { if (format_ptr == NULL) {
fprintf(out, "#\n# Fatal libcurl error\n"); fprintf(out, "#\n# Fatal libcurl error\n");
if(!use_stdout)
fclose(out);
return 1; return 1;
} }
fprintf(out, "%s\n", format_ptr); fprintf(out, "%s\n", format_ptr);

View File

@ -1248,8 +1248,8 @@ create_sconv_object(const char *fc, const char *tc,
} }
sc->to_charset = strdup(tc); sc->to_charset = strdup(tc);
if (sc->to_charset == NULL) { if (sc->to_charset == NULL) {
free(sc);
free(sc->from_charset); free(sc->from_charset);
free(sc);
return (NULL); return (NULL);
} }
archive_string_init(&sc->utftmp); archive_string_init(&sc->utftmp);