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@outlook.pt>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
João Diogo Ferreira 2019-11-17 18:22:35 +00:00 committed by Alexandre Julliard
parent 27afc0d3ab
commit c790422daa
1 changed files with 10 additions and 16 deletions

View File

@ -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:
case GEO_ISO3:
{
str = geotype == GEO_ISO2 ? ptr->iso2W : ptr->iso3W;
str = ptr->iso2W;
break;
case GEO_ISO3:
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;