ref: be45b255275fb26c264361ccd28dd8f8999858a4
parent: 293b22549c00c996f3c88e00365c78a4ad980b64
parent: 9be786f9a5a7019d465eb9f11dcc143bad388579
author: Michael Francis <mikefrancis95@gmail.com>
date: Thu Jul 9 17:07:46 EDT 2020
Merge pull request #1300 from mfrancis95/formatstringfix When running sscanf on numbers in hex or octal, make sure the argumen…
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -1371,10 +1371,10 @@
if (env != NULL)
{
char winenv[30];
- int winid;
+ unsigned int winid;
sscanf(env, "0x%x", &winid);
- M_snprintf(winenv, sizeof(winenv), "SDL_WINDOWID=%i", winid);
+ M_snprintf(winenv, sizeof(winenv), "SDL_WINDOWID=%u", winid);
putenv(winenv);
}
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -1923,7 +1923,7 @@
int parm;
if (strparm[0] == '0' && strparm[1] == 'x')
- sscanf(strparm+2, "%x", &parm);
+ sscanf(strparm+2, "%x", (unsigned int *) &parm);
else
sscanf(strparm, "%i", &parm);
--- a/src/m_misc.c
+++ b/src/m_misc.c
@@ -259,9 +259,9 @@
boolean M_StrToInt(const char *str, int *result)
{
- return sscanf(str, " 0x%x", result) == 1
- || sscanf(str, " 0X%x", result) == 1
- || sscanf(str, " 0%o", result) == 1
+ return sscanf(str, " 0x%x", (unsigned int *) result) == 1
+ || sscanf(str, " 0X%x", (unsigned int *) result) == 1
+ || sscanf(str, " 0%o", (unsigned int *) result) == 1
|| sscanf(str, " %d", result) == 1;
}