contrib: fixed resource leak in parsertrace

make-http-max-header-size-gyp-configurable
Alex Butum 11 years ago committed by Fedor Indutny
parent 24e2d2d43f
commit d19e12911a

@ -111,14 +111,14 @@ int main(int argc, char* argv[]) {
FILE* file = fopen(filename, "r");
if (file == NULL) {
perror("fopen");
return EXIT_FAILURE;
goto fail;
}
fseek(file, 0, SEEK_END);
long file_length = ftell(file);
if (file_length == -1) {
perror("ftell");
return EXIT_FAILURE;
goto fail;
}
fseek(file, 0, SEEK_SET);
@ -126,7 +126,7 @@ int main(int argc, char* argv[]) {
if (fread(data, 1, file_length, file) != (size_t)file_length) {
fprintf(stderr, "couldn't read entire file\n");
free(data);
return EXIT_FAILURE;
goto fail;
}
http_parser_settings settings;
@ -149,8 +149,12 @@ int main(int argc, char* argv[]) {
"Error: %s (%s)\n",
http_errno_description(HTTP_PARSER_ERRNO(&parser)),
http_errno_name(HTTP_PARSER_ERRNO(&parser)));
return EXIT_FAILURE;
goto fail;
}
return EXIT_SUCCESS;
fail:
fclose(file);
return EXIT_FAILURE;
}

Loading…
Cancel
Save