aviralgarg05 commented on code in PR #3644:
URL: https://github.com/apache/nuttx-apps/pull/3644#discussion_r3789187273
##########
games/NXDoom/src/m_config.c:
##########
@@ -1982,16 +1982,14 @@ static void
save_default_collection(default_collection_t *collection)
*
****************************************************************************/
-static int parse_int_parameter(const char *strparm)
+static int parse_int_parameter(const char *strparm, int *param)
{
- int param;
-
if (strparm[0] == '0' && strparm[1] == 'x')
- sscanf(strparm + 2, "%x", (unsigned int *)¶m);
- else
- sscanf(strparm, "%i", ¶m);
+ {
+ return sscanf(strparm + 2, "%x", (unsigned int *)param) == 1;
+ }
- return param;
+ return sscanf(strparm, "%i", param) == 1;
Review Comment:
Fixed
##########
games/NXDoom/src/m_config.c:
##########
@@ -2096,12 +2103,28 @@ static void
load_default_collection(default_collection_t *collection)
return;
}
- while (!feof(f))
+ while (fgets(line, sizeof(line), f) != NULL)
{
- if (fscanf(f, "%79s %99[^\n]\n", defname, strparm) != 2)
+ strparm[0] = '\0';
+
+ /* Parse one physical line at a time. fscanf() with whitespace in
+ * its format can consume the next line as a missing value.
+ */
+
+ if (strchr(line, '\n') == NULL &&
+ strlen(line) == sizeof(line) - 1)
{
- /* This line doesn't match */
+ int ch;
+
+ while ((ch = fgetc(f)) != '\n' && ch != EOF)
+ {
+ }
Review Comment:
Fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]