Hugh McMaster : regedit: Free the memory used by the REG_DWORD and hex data types after saving the registry value.
Alexandre Julliard
julliard at winehq.org
Fri Jun 16 18:15:09 CDT 2017
Module: wine
Branch: master
Commit: 8504a1563de17f7c93023cf317a7bccde7718d17
URL: http://source.winehq.org/git/wine.git/?a=commit;h=8504a1563de17f7c93023cf317a7bccde7718d17
Author: Hugh McMaster <hugh.mcmaster at outlook.com>
Date: Fri Jun 16 13:06:23 2017 +0000
regedit: Free the memory used by the REG_DWORD and hex data types after saving the registry value.
We use a BOOL to handle all hex types, including those that are undefined (e.g.0x100).
Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
programs/regedit/regproc.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/programs/regedit/regproc.c b/programs/regedit/regproc.c
index f7e8d2a..416938d 100644
--- a/programs/regedit/regproc.c
+++ b/programs/regedit/regproc.c
@@ -163,6 +163,7 @@ struct parser
DWORD data_type; /* data type */
void *data; /* value data */
DWORD data_size; /* size of the data (in bytes) */
+ BOOL hex_type; /* parsing a hex data type */
enum parser_state state; /* current parser state */
};
@@ -322,6 +323,7 @@ static BOOL parse_data_type(struct parser *parser, WCHAR **line)
return FALSE;
parser->data_type = val;
+ parser->hex_type = TRUE;
*line = end + 2;
}
return TRUE;
@@ -826,6 +828,13 @@ static WCHAR *set_value_state(struct parser *parser, WCHAR *pos)
RegSetValueExW(parser->hkey, parser->value_name, 0, parser->data_type,
parser->data, parser->data_size);
+ if (parser->data_type == REG_DWORD || parser->hex_type)
+ {
+ HeapFree(GetProcessHeap(), 0, parser->data);
+ parser->data = NULL;
+ parser->hex_type = FALSE;
+ }
+
if (parser->reg_version == REG_VERSION_31)
set_state(parser, PARSE_WIN31_LINE);
else
@@ -1463,6 +1472,7 @@ BOOL import_registry_file(FILE *reg_file)
parser.data_type = 0;
parser.data = NULL;
parser.data_size = 0;
+ parser.hex_type = FALSE;
parser.state = HEADER;
pos = parser.two_wchars;
More information about the wine-cvs
mailing list