[PATCH 1/3] kernel32: Fix null pointer access in GetGeoInfoW().
João Diogo Ferreira
devilj at outlook.pt
Sun Nov 17 12:22:35 CST 2019
We were failing the conditional that would point «str» to «buffW»
when retrieving the GEO_ISO_UN_NUMBER of a location with UN code 0.
Some locations will keep having no UN code, such as Guantanamo Bay or
Johnston Atoll, since that's how those are defined in Windows.
Signed-off-by: João Diogo Craveiro Ferreira <devilj at outlook.pt>
---
dlls/kernel32/locale.c | 24 +++++++++---------------
1 file changed, 9 insertions(+), 15 deletions(-)
diff --git a/dlls/kernel32/locale.c b/dlls/kernel32/locale.c
index 0f91728e84..086389b45f 100644
--- a/dlls/kernel32/locale.c
+++ b/dlls/kernel32/locale.c
@@ -4109,10 +4109,10 @@ BOOL WINAPI SetUserGeoID(GEOID geoid)
INT WINAPI GetGeoInfoW(GEOID geoid, GEOTYPE geotype, LPWSTR data, int data_len, LANGID lang)
{
const struct geoinfo_t *ptr;
- const WCHAR *str = NULL;
WCHAR buffW[12];
- LONG val = 0;
- INT len;
+ const WCHAR *str = buffW;
+ int len;
+ static const WCHAR fmtW[] = {'%','d',0};
TRACE("%d %d %p %d %d\n", geoid, geotype, data, data_len, lang);
@@ -4123,20 +4123,20 @@ INT WINAPI GetGeoInfoW(GEOID geoid, GEOTYPE geotype, LPWSTR data, int data_len,
switch (geotype) {
case GEO_NATION:
- val = geoid;
+ sprintfW(buffW, fmtW, ptr->id);
break;
case GEO_ISO_UN_NUMBER:
- val = ptr->uncode;
+ sprintfW(buffW, fmtW, ptr->uncode);
break;
case GEO_PARENT:
- val = ptr->parent;
+ sprintfW(buffW, fmtW, ptr->parent);
break;
case GEO_ISO2:
+ str = ptr->iso2W;
+ break;
case GEO_ISO3:
- {
- str = geotype == GEO_ISO2 ? ptr->iso2W : ptr->iso3W;
+ str = ptr->iso3W;
break;
- }
case GEO_RFC1766:
case GEO_LCID:
case GEO_FRIENDLYNAME:
@@ -4154,12 +4154,6 @@ INT WINAPI GetGeoInfoW(GEOID geoid, GEOTYPE geotype, LPWSTR data, int data_len,
return 0;
}
- if (val) {
- static const WCHAR fmtW[] = {'%','d',0};
- sprintfW(buffW, fmtW, val);
- str = buffW;
- }
-
len = strlenW(str) + 1;
if (!data || !data_len)
return len;
--
2.24.0
More information about the wine-devel
mailing list