Skip to content
Snippets Groups Projects
Commit a8fb3d78 authored by Vincent Béron's avatar Vincent Béron Committed by Alexandre Julliard
Browse files

Fix strncpyWtoA to actually act as advertised (and not overflow the

input buffer).
Small cleanups of it at the same time.
parent ad1a1064
No related branches found
No related tags found
No related merge requests found
......@@ -81,13 +81,12 @@ char *get_typename(resource_t* r)
char *strncpyWtoA(char *cs, short *ws, int maxlen)
{
char *cptr = cs;
short *wsMax = ws + maxlen;
while(ws < wsMax)
short *wsMax = ws + maxlen - 1;
while(*ws && ws < wsMax)
{
if(*ws < -128 || *ws > 127)
printf("***Warning: Unicode string contains non-printable chars***");
fprintf(stderr, "***Warning: Unicode string contains non-printable chars***\n");
*cptr++ = (char)*ws++;
maxlen--;
}
*cptr = '\0';
return cs;
......@@ -1047,4 +1046,3 @@ void dump_resources(resource_t *top)
top = top->next;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment