Call wine_cp_wcstombs() to retrieve actual length of buffer before
conversion.
This commit is contained in:
parent
907ac44aa7
commit
216ba4f0d3
|
@ -94,12 +94,14 @@ static char str_header[] =
|
||||||
|
|
||||||
static char *dup_u2c(int cp, const WCHAR *uc)
|
static char *dup_u2c(int cp, const WCHAR *uc)
|
||||||
{
|
{
|
||||||
int len = unistrlen(uc);
|
int len;
|
||||||
char *cptr = xmalloc(len+1);
|
char *cptr;
|
||||||
const union cptable *cpdef = find_codepage(cp);
|
const union cptable *cpdef = find_codepage(cp);
|
||||||
if(!cpdef)
|
if(!cpdef)
|
||||||
internal_error(__FILE__, __LINE__, "Codepage %d not found (vanished?)", cp);
|
internal_error(__FILE__, __LINE__, "Codepage %d not found (vanished?)", cp);
|
||||||
if((len = wine_cp_wcstombs(cpdef, 0, uc, unistrlen(uc)+1, cptr, len+1, NULL, NULL)) < 0)
|
len = wine_cp_wcstombs(cpdef, 0, uc, unistrlen(uc)+1, NULL, 0, NULL, NULL);
|
||||||
|
cptr = xmalloc(len);
|
||||||
|
if((len = wine_cp_wcstombs(cpdef, 0, uc, unistrlen(uc)+1, cptr, len, NULL, NULL)) < 0)
|
||||||
internal_error(__FILE__, __LINE__, "Buffer overflow? code %d.", len);
|
internal_error(__FILE__, __LINE__, "Buffer overflow? code %d.", len);
|
||||||
return cptr;
|
return cptr;
|
||||||
}
|
}
|
||||||
|
@ -377,12 +379,14 @@ static char *make_string(WCHAR *uc, int len, int codepage)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *tmp = xmalloc(2*len+1);
|
char *tmp, *cc;
|
||||||
char *cc = tmp;
|
int mlen;
|
||||||
const union cptable *cpdef = find_codepage(codepage);
|
const union cptable *cpdef = find_codepage(codepage);
|
||||||
|
|
||||||
assert(cpdef != NULL);
|
assert(cpdef != NULL);
|
||||||
if((i = wine_cp_wcstombs(cpdef, 0, uc, unistrlen(uc)+1, tmp, 2*len+1, NULL, NULL)) < 0)
|
mlen = wine_cp_wcstombs(cpdef, 0, uc, unistrlen(uc)+1, NULL, 0, NULL, NULL);
|
||||||
|
cc = tmp = xmalloc(mlen);
|
||||||
|
if((i = wine_cp_wcstombs(cpdef, 0, uc, unistrlen(uc)+1, tmp, mlen, NULL, NULL)) < 0)
|
||||||
internal_error(__FILE__, __LINE__, "Buffer overflow? code %d.", i);
|
internal_error(__FILE__, __LINE__, "Buffer overflow? code %d.", i);
|
||||||
*cptr++ = ' ';
|
*cptr++ = ' ';
|
||||||
*cptr++ = '"';
|
*cptr++ = '"';
|
||||||
|
|
Loading…
Reference in New Issue