oleaut32: Handle xbuf_get erroring out in deserialize_param (and avoid uninitialized read).

Gerald Pfeifer gerald at pfeifer.com
Mon Sep 19 02:46:36 CDT 2016


GCC trunk started to warn as follows a week or two ago

  tmarshal.c:1092:3: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
  tmarshal.c:1082:3: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]

and looking into the source in case of an error in xbuf_get, the
variable x indeed is not set.

Gerald

Signed-off-by: Gerald Pfeifer <gerald at pfeifer.com>
---
 dlls/oleaut32/tmarshal.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/dlls/oleaut32/tmarshal.c b/dlls/oleaut32/tmarshal.c
index 5fd1fdd..3738588 100644
--- a/dlls/oleaut32/tmarshal.c
+++ b/dlls/oleaut32/tmarshal.c
@@ -1078,7 +1078,10 @@ deserialize_param(
 	    if (readit) {
 		DWORD x;
 		hres = xbuf_get(buf,(LPBYTE)&x,sizeof(DWORD));
-		if (hres) ERR("Failed to read integer 4 byte\n");
+		if (hres) {
+		    ERR("Failed to read integer 4 byte\n");
+		    x = 0;
+		}
 		memcpy(arg,&x,2);
 	    }
 	    if (debugout) TRACE_(olerelay)("%04x",*arg & 0xffff);
@@ -1088,7 +1091,10 @@ deserialize_param(
 	    if (readit) {
 		DWORD x;
 		hres = xbuf_get(buf,(LPBYTE)&x,sizeof(DWORD));
-		if (hres) ERR("Failed to read integer 4 byte\n");
+		if (hres) {
+		    ERR("Failed to read integer 4 byte\n");
+		    x = 0;
+		}
 		memcpy(arg,&x,1);
 	    }
 	    if (debugout) TRACE_(olerelay)("%02x",*arg & 0xff);
-- 
2.9.2



More information about the wine-patches mailing list