1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-24 13:50:49 +03:00

Coding - Incorrect return-value check for a 'scanf'-like function (#680)

Fix sscanf condition checks in iges_lire function for better error handling
This commit is contained in:
Pasukhin Dmitry
2025-08-17 21:01:32 +01:00
committed by GitHub
parent 3eb7ce1ffd
commit 5c8756830f

View File

@@ -102,7 +102,7 @@ int iges_lire (FILE* lefic, int *numsec, char line[100], int modefnes)
if (line[0] == '\0' || line[0] == '\n' || line[0] == '\r')
return iges_lire(lefic,numsec,line,modefnes); /* 0 */
if (sscanf(&line[73],"%d",&result) != 0) {
if (sscanf(&line[73],"%d",&result) == 1) {
*numsec = result;
typesec = line[72];
switch (typesec) {
@@ -146,7 +146,7 @@ int iges_lire (FILE* lefic, int *numsec, char line[100], int modefnes)
// find the number start
while (line[i] >= '0' && line[i] <= '9' && i > 0)
i--;
if (sscanf(&line[i + 1],"%d",&result) == 0)
if (sscanf(&line[i + 1],"%d",&result) != 1)
return -1;
*numsec = result;
// find type of line