Skip to content

Commit 5e9228d

Browse files
committed
- Error-handling
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@9595 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 8e51775 commit 5e9228d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

c_runtime/ModelicaExternalC/ModelicaInternal.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,7 @@ static const char* ModelicaInternal_readLine(const char* fileName, int lineNumbe
622622
size_t lineLen;
623623
size_t iLines;
624624
long offset;
625+
if (!fp) goto ERROR;
625626

626627
/* Read upto line lineNumber-1 */
627628
iLines = 0;
@@ -661,7 +662,7 @@ static const char* ModelicaInternal_readLine(const char* fileName, int lineNumbe
661662
line = ModelicaAllocateString(0);
662663
return line;
663664

664-
ERROR : fclose(fp);
665+
ERROR : if (fp) fclose(fp);
665666
ModelicaFormatError("Error when reading line %i from file\n\"%s\":\n%s",
666667
lineNumber, fileName, strerror(errno));
667668
return "";

0 commit comments

Comments
 (0)