Francois Gouget : regedit: Fix handling of zero-byte binary values for ' regedit /E'.

Alexandre Julliard julliard at winehq.org
Mon Nov 24 09:16:37 CST 2008


Module: wine
Branch: master
Commit: c880ccea1a1e4239256c1af018cca142833fa5af
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=c880ccea1a1e4239256c1af018cca142833fa5af

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Sun Nov 23 20:54:45 2008 +0100

regedit: Fix handling of zero-byte binary values for 'regedit /E'.

---

 programs/regedit/regproc.c |   39 +++++++++++++++++++++------------------
 1 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/programs/regedit/regproc.c b/programs/regedit/regproc.c
index 56d7a5a..c1aee21 100644
--- a/programs/regedit/regproc.c
+++ b/programs/regedit/regproc.c
@@ -927,12 +927,10 @@ static void REGPROC_export_string(WCHAR **line_buf, DWORD *line_buf_size, DWORD
 
 static void REGPROC_export_binary(WCHAR **line_buf, DWORD *line_buf_size, DWORD *line_len, DWORD type, BYTE *value, DWORD value_size, BOOL unicode)
 {
-    DWORD i, hex_pos, data_pos, column;
+    DWORD hex_pos, data_pos;
     const WCHAR *hex_prefix;
     const WCHAR hex[] = {'h','e','x',':',0};
     WCHAR hex_buf[17];
-    const WCHAR format[] = {'%','0','2','x',0};
-    const WCHAR comma[] = {',',0};
     const WCHAR concat[] = {'\\','\n',' ',' ',0};
     DWORD concat_prefix, concat_len;
     const WCHAR newline[] = {'\n',0};
@@ -969,24 +967,29 @@ static void REGPROC_export_binary(WCHAR **line_buf, DWORD *line_buf_size, DWORD
     *line_len += *line_len / (REG_FILE_HEX_LINE_LEN - concat_prefix) * concat_len;
     REGPROC_resize_char_buffer(line_buf, line_buf_size, *line_len);
     lstrcpyW(*line_buf + hex_pos, hex_prefix);
-    column = data_pos; /* no line wrap yet */
-    i = 0;
-    while (1)
+    if (value_size)
     {
-        sprintfW(*line_buf + data_pos, format, (unsigned int)value[i]);
-        data_pos += 2;
-        if (++i == value_size)
-            break;
+        const WCHAR format[] = {'%','0','2','x',0};
+        DWORD i, column;
+
+        column = data_pos; /* no line wrap yet */
+        i = 0;
+        while (1)
+        {
+            sprintfW(*line_buf + data_pos, format, (unsigned int)value[i]);
+            data_pos += 2;
+            if (++i == value_size)
+                break;
 
-        lstrcpyW(*line_buf + data_pos, comma);
-        data_pos++;
-        column += 3;
+            (*line_buf)[data_pos++] = ',';
+            column += 3;
 
-        /* wrap the line */
-        if (column >= REG_FILE_HEX_LINE_LEN) {
-            lstrcpyW(*line_buf + data_pos, concat);
-            data_pos += concat_len;
-            column = concat_prefix;
+            /* wrap the line */
+            if (column >= REG_FILE_HEX_LINE_LEN) {
+                lstrcpyW(*line_buf + data_pos, concat);
+                data_pos += concat_len;
+                column = concat_prefix;
+            }
         }
     }
     lstrcpyW(*line_buf + data_pos, newline);




More information about the wine-cvs mailing list