Skip to content

Commit 5c87568

Browse files
authored
Coding - Incorrect return-value check for a 'scanf'-like function (#680)
Fix sscanf condition checks in iges_lire function for better error handling
1 parent 3eb7ce1 commit 5c87568

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/DataExchange/TKDEIGES/IGESFile/liriges.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ int iges_lire (FILE* lefic, int *numsec, char line[100], int modefnes)
102102
if (line[0] == '\0' || line[0] == '\n' || line[0] == '\r')
103103
return iges_lire(lefic,numsec,line,modefnes); /* 0 */
104104

105-
if (sscanf(&line[73],"%d",&result) != 0) {
105+
if (sscanf(&line[73],"%d",&result) == 1) {
106106
*numsec = result;
107107
typesec = line[72];
108108
switch (typesec) {
@@ -146,7 +146,7 @@ int iges_lire (FILE* lefic, int *numsec, char line[100], int modefnes)
146146
// find the number start
147147
while (line[i] >= '0' && line[i] <= '9' && i > 0)
148148
i--;
149-
if (sscanf(&line[i + 1],"%d",&result) == 0)
149+
if (sscanf(&line[i + 1],"%d",&result) != 1)
150150
return -1;
151151
*numsec = result;
152152
// find type of line

0 commit comments

Comments
 (0)