Mesa (master): d3d12: Fix uninitialized variable referenced in error case

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Jan 3 23:24:44 UTC 2021


Module: Mesa
Branch: master
Commit: ca5df4273e0a14b590694c918a15f63a68bf4073
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=ca5df4273e0a14b590694c918a15f63a68bf4073

Author: Jesse Natalie <jenatali at microsoft.com>
Date:   Mon Dec 28 10:52:44 2020 -0800

d3d12: Fix uninitialized variable referenced in error case

Clang warns that errorString is uninitialized if printBlobUtf8
is null, meaning GetBlobAsUtf8 failed, but then we go ahead and
access it (and printBlobUtf8) after the if. Expand the if to
encompass the printing.

Fixes: 2ea15cd6 ("d3d12: introduce d3d12 gallium driver")

Reviewed-by: Adam Jackson <ajax at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8248>

---

 src/gallium/drivers/d3d12/d3d12_compiler.cpp | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/d3d12/d3d12_compiler.cpp b/src/gallium/drivers/d3d12/d3d12_compiler.cpp
index 208ddfc7d59..268e23d2201 100644
--- a/src/gallium/drivers/d3d12/d3d12_compiler.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_compiler.cpp
@@ -1269,12 +1269,12 @@ bool d3d12_validation_tools::validate_and_sign(struct blob *dxil)
       char *errorString;
       if (printBlobUtf8) {
          errorString = reinterpret_cast<char*>(printBlobUtf8->GetBufferPointer());
-      }
 
-      errorString[printBlobUtf8->GetBufferSize() - 1] = 0;
-      debug_printf("== VALIDATION ERROR =============================================\n%s\n"
-                   "== END ==========================================================\n",
-                   errorString);
+         errorString[printBlobUtf8->GetBufferSize() - 1] = 0;
+         debug_printf("== VALIDATION ERROR =============================================\n%s\n"
+                     "== END ==========================================================\n",
+                     errorString);
+      }
 
       return false;
    }



More information about the mesa-commit mailing list