[v2 PATCH] d3dx9_36: Stop crash when displaying effect errors

Alistair Leslie-Hughes leslie_alistair at hotmail.com
Wed Jun 22 06:10:18 CDT 2016


v2: Break the buffer up at carriage returns.

Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
---
 dlls/d3dx9_36/effect.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/dlls/d3dx9_36/effect.c b/dlls/d3dx9_36/effect.c
index fd8d59e..6c2c50d 100644
--- a/dlls/d3dx9_36/effect.c
+++ b/dlls/d3dx9_36/effect.c
@@ -5969,7 +5969,26 @@ static HRESULT d3dx9_base_effect_init(struct d3dx9_base_effect *base,
             if (bytecode)
                 ID3D10Blob_Release(bytecode);
             if (temp_errors)
-                TRACE("%s\n", (char *)ID3D10Blob_GetBufferPointer(temp_errors));
+            {
+                const char *p = ID3D10Blob_GetBufferPointer(temp_errors);
+                SIZE_T size = ID3D10Blob_GetBufferSize(temp_errors);
+                const char *end = p + size;
+                const char *line = p;
+
+                while (p != end)
+                {
+                    if (*p == '\n')
+                    {
+                        UINT len = p - line;
+                        if (len && *(p - 1) == '\r') --len;
+                        TRACE("%s\n", debugstr_an(line, len));
+                        line = ++p;
+                    }
+                    else ++p;
+                }
+                if (line != p)
+                    TRACE("%s\n", debugstr_an(line, p - line));
+            }
             if (errors)
                 *errors = temp_errors;
             else if (temp_errors)
-- 
2.8.1




More information about the wine-patches mailing list