From 5c8756830f73d5215559e23738f23cbc97fa5179 Mon Sep 17 00:00:00 2001 From: Pasukhin Dmitry Date: Sun, 17 Aug 2025 21:01:32 +0100 Subject: [PATCH] Coding - Incorrect return-value check for a 'scanf'-like function (#680) Fix sscanf condition checks in iges_lire function for better error handling --- src/DataExchange/TKDEIGES/IGESFile/liriges.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DataExchange/TKDEIGES/IGESFile/liriges.c b/src/DataExchange/TKDEIGES/IGESFile/liriges.c index 2e35714694..d87716218e 100644 --- a/src/DataExchange/TKDEIGES/IGESFile/liriges.c +++ b/src/DataExchange/TKDEIGES/IGESFile/liriges.c @@ -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 -- 2.39.5