mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-09-03 14:10:33 +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:
@@ -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')
|
if (line[0] == '\0' || line[0] == '\n' || line[0] == '\r')
|
||||||
return iges_lire(lefic,numsec,line,modefnes); /* 0 */
|
return iges_lire(lefic,numsec,line,modefnes); /* 0 */
|
||||||
|
|
||||||
if (sscanf(&line[73],"%d",&result) != 0) {
|
if (sscanf(&line[73],"%d",&result) == 1) {
|
||||||
*numsec = result;
|
*numsec = result;
|
||||||
typesec = line[72];
|
typesec = line[72];
|
||||||
switch (typesec) {
|
switch (typesec) {
|
||||||
@@ -146,7 +146,7 @@ int iges_lire (FILE* lefic, int *numsec, char line[100], int modefnes)
|
|||||||
// find the number start
|
// find the number start
|
||||||
while (line[i] >= '0' && line[i] <= '9' && i > 0)
|
while (line[i] >= '0' && line[i] <= '9' && i > 0)
|
||||||
i--;
|
i--;
|
||||||
if (sscanf(&line[i + 1],"%d",&result) == 0)
|
if (sscanf(&line[i + 1],"%d",&result) != 1)
|
||||||
return -1;
|
return -1;
|
||||||
*numsec = result;
|
*numsec = result;
|
||||||
// find type of line
|
// find type of line
|
||||||
|
Reference in New Issue
Block a user