Commit fe3c8740 authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

detect fclose(NULL)

parent d9459b54
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -200,7 +200,15 @@ FILE *curl_fopen(const char *file, const char *mode,

int curl_fclose(FILE *file, int line, const char *source)
{
  int res=(fclose)(file);
  int res;

  if(NULL == file) {
    fprintf(stderr, "ILLEGAL flose() on NULL at %s:%d\n",
            source, line);
    exit(2);
  }

  res=(fclose)(file);
  if(logfile)
    fprintf(logfile, "FILE %s:%d fclose(%p)\n",
            source, line, file);