João Diogo Ferreira : kernel32: Fix null pointer access in GetGeoInfoW().
Alexandre Julliard
julliard at winehq.org
Mon Nov 18 16:19:18 CST 2019
Module: wine
Branch: master
Commit: c790422daa4520e9f23111e8a2052cebff584abd
URL: https://source.winehq.org/git/wine.git/?a=commit;h=c790422daa4520e9f23111e8a2052cebff584abd
Author: João Diogo Ferreira <devilj at outlook.pt>
Date: Sun Nov 17 18:22:35 2019 +0000
kernel32: Fix null pointer access in GetGeoInfoW().
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>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
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 323110daa6..18edc8f7ba 100644
--- a/dlls/kernel32/locale.c
+++ b/dlls/kernel32/locale.c
@@ -4171,10 +4171,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);
@@ -4185,20 +4185,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:
@@ -4216,12 +4216,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;
More information about the wine-cvs
mailing list