Henri Verbeet : d3dcompiler: Free the filename if we don' t store it in the HLSL preproc_directive rule (Valgrind).

Alexandre Julliard julliard at wine.codeweavers.com
Fri May 1 07:50:09 CDT 2015


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

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Thu Apr 30 16:46:37 2015 +0200

d3dcompiler: Free the filename if we don't store it in the HLSL preproc_directive rule (Valgrind).

---

 dlls/d3dcompiler_43/hlsl.y | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y
index f37e07e..80fe0e6 100644
--- a/dlls/d3dcompiler_43/hlsl.y
+++ b/dlls/d3dcompiler_43/hlsl.y
@@ -1097,20 +1097,23 @@ hlsl_prog:                /* empty */
 
 preproc_directive:        PRE_LINE STRING
                             {
+                                const char **new_array = NULL;
+
                                 TRACE("Updating line information to file %s, line %u\n", debugstr_a($2), $1);
                                 hlsl_ctx.line_no = $1;
                                 if (strcmp($2, hlsl_ctx.source_file))
-                                {
-                                    const char **new_array;
-
-                                    hlsl_ctx.source_file = $2;
                                     new_array = d3dcompiler_realloc(hlsl_ctx.source_files,
                                             sizeof(*hlsl_ctx.source_files) * hlsl_ctx.source_files_count + 1);
-                                    if (new_array)
-                                    {
-                                        hlsl_ctx.source_files = new_array;
-                                        hlsl_ctx.source_files[hlsl_ctx.source_files_count++] = $2;
-                                    }
+
+                                if (new_array)
+                                {
+                                    hlsl_ctx.source_files = new_array;
+                                    hlsl_ctx.source_files[hlsl_ctx.source_files_count++] = $2;
+                                    hlsl_ctx.source_file = $2;
+                                }
+                                else
+                                {
+                                    d3dcompiler_free($2);
                                 }
                             }
 




More information about the wine-cvs mailing list