From 76b9e6c712bfa129afec746f4e986a5fbdedbd98 Mon Sep 17 00:00:00 2001 From: Hugh McMaster Date: Wed, 3 May 2017 11:28:26 +0000 Subject: [PATCH] regedit: Return a Unicode line from get_lineA(). Signed-off-by: Hugh McMaster Signed-off-by: Alexandre Julliard --- programs/regedit/regproc.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/programs/regedit/regproc.c b/programs/regedit/regproc.c index 9740293ff7d..282800ed76d 100644 --- a/programs/regedit/regproc.c +++ b/programs/regedit/regproc.c @@ -671,12 +671,15 @@ static enum reg_versions parse_file_header(WCHAR *s) return REG_VERSION_INVALID; } -static char *get_lineA(FILE *fp) +static WCHAR *get_lineA(FILE *fp) { + static WCHAR *lineW; static size_t size; static char *buf, *next; char *line; + HeapFree(GetProcessHeap(), 0, lineW); + if (!fp) goto cleanup; if (!size) @@ -707,7 +710,8 @@ static char *get_lineA(FILE *fp) if (!(count = fread(buf + len, 1, size - len - 1, fp))) { next = NULL; - return buf; + lineW = GetWideString(buf); + return lineW; } buf[len + count] = 0; next = buf; @@ -730,10 +734,12 @@ static char *get_lineA(FILE *fp) line = next; continue; } - return line; + lineW = GetWideString(line); + return lineW; } cleanup: + lineW = NULL; if (size) HeapFree(GetProcessHeap(), 0, buf); size = 0; return NULL; @@ -741,22 +747,19 @@ cleanup: static BOOL processRegLinesA(FILE *fp, char *two_chars) { - char *line, *header; - WCHAR *lineW; + WCHAR *line, *header; int reg_version; line = get_lineA(fp); - header = HeapAlloc(GetProcessHeap(), 0, strlen(line) + 3); + header = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(line) + 3) * sizeof(WCHAR)); CHECK_ENOUGH_MEMORY(header); - strcpy(header, two_chars); - strcpy(header + 2, line); + header[0] = two_chars[0]; + header[1] = two_chars[1]; + lstrcpyW(header + 2, line); - lineW = GetWideString(header); + reg_version = parse_file_header(header); HeapFree(GetProcessHeap(), 0, header); - - reg_version = parse_file_header(lineW); - HeapFree(GetProcessHeap(), 0, lineW); if (reg_version == REG_VERSION_FUZZY || reg_version == REG_VERSION_INVALID) { get_lineA(NULL); /* Reset static variables */ @@ -765,14 +768,10 @@ static BOOL processRegLinesA(FILE *fp, char *two_chars) while ((line = get_lineA(fp))) { - lineW = GetWideString(line); - if (reg_version == REG_VERSION_31) - processRegEntry31(lineW); + processRegEntry31(line); else - processRegEntry(lineW, FALSE); - - HeapFree(GetProcessHeap(), 0, lineW); + processRegEntry(line, FALSE); } closeKey();