Index: chrome_elf/nt_registry/nt_registry.cc |
diff --git a/chrome_elf/nt_registry/nt_registry.cc b/chrome_elf/nt_registry/nt_registry.cc |
index 4c65af8daff7c76ea5a9e4a0255da0225aeb58a4..354cc6478a7ad797c71322a6c309942505bff679 100644 |
--- a/chrome_elf/nt_registry/nt_registry.cc |
+++ b/chrome_elf/nt_registry/nt_registry.cc |
@@ -775,10 +775,15 @@ bool QueryRegKeyValue(HANDLE key, |
if (NT_SUCCESS(ntstatus)) { |
*out_type = value_info->Type; |
*out_size = value_info->DataLength; |
- *out_buffer = new BYTE[*out_size]; |
- ::memcpy(*out_buffer, |
- (reinterpret_cast<BYTE*>(value_info) + value_info->DataOffset), |
- *out_size); |
+ *out_buffer = nullptr; |
+ if (*out_size) { |
+ *out_buffer = new BYTE[*out_size]; |
robertshield
2017/05/17 16:59:59
totally optional, as this looks right to me, but f
penny
2017/07/19 22:25:15
Done. For the query function, a vector of bytes i
|
+ ::memcpy(*out_buffer, |
+ (reinterpret_cast<BYTE*>(value_info) + value_info->DataOffset), |
+ *out_size); |
+ if (*out_type == REG_SZ || *out_type == REG_MULTI_SZ) |
robertshield
2017/05/17 16:59:59
how about REG_EXPAND_SZ?
penny
2017/07/19 22:25:15
Done. Thanks for noting this Robert. Mine as well
|
+ (*out_buffer)[(*out_size) - 1] = 0; |
+ } |
success = true; |
} |