Mon 23 Apr 2012 08:26:36 PM UTC, original submission:
We are developing a tool to find bugs, and it flagged a potential error in CVS.
We are checking CVS version 1.11.23.
In parse_config() in src/parseinfo.c, the config file is opened at line 274:
274: fp_info = CVS_FOPEN (infopath, "r");
The file is closed if everything goes well:
461: if (fclose (fp_info) < 0)
But if there is a syntax error, the file is not closed:
321: p = strchr (line, '=');
322: if (p == NULL)
323: {
323: /* Probably should be printing line number. */
324: error (0, 0, "syntax error in %s: line '%s' is missing '='",
325: infopath, line);
326: goto error_return;
327: }
...
474: error_return:
475: if (!logHistory)
476: logHistory = xstrdup (ALL_HISTORY_REC_TYPES);
477: if (infopath != NULL)
478: free (infopath);
479: if (line != NULL)
480: free (line);
// Shall we have something like
// if (fp_info) fclose(fp_info);
// here?
481: return -1;
482:}
Since the problem is due to a syntax error, shall we still close the file?
We may just move the call to fclose() into the error_return block.
Else the file would be left opened after the function returns.
Is this a real problem? Any confirmation or clarification is
appreciated. Thanks.
|