[svn] MOJOSHADER_parseData needs to hold app-defined allocators even when there's trunk
authoricculus
Thu, 27 Mar 2008 23:07:44 -0400
branchtrunk
changeset 51 b3978661fd6b
parent 50 427f32b5eeff
child 52 305ddf21d660
[svn] MOJOSHADER_parseData needs to hold app-defined allocators even when there's an error, so we use the right free() when they are down with the object.
mojoshader.c
--- a/mojoshader.c	Thu Mar 27 23:06:57 2008 -0400
+++ b/mojoshader.c	Thu Mar 27 23:07:44 2008 -0400
@@ -2602,7 +2602,7 @@
     if (isfail(ctx))
     {
         if (output != NULL)
-            ctx->free(output);  // just in case.
+            ctx->free(output);
         retval->error = ctx->failstr;  // we recycle.  :)
         ctx->failstr = NULL;  // don't let this get free()'d too soon.
     } // if
@@ -2614,10 +2614,11 @@
         retval->shader_type = ctx->shader_type;
         retval->major_ver = (int) ctx->major_ver;
         retval->minor_ver = (int) ctx->minor_ver;
-        retval->malloc = (ctx->malloc == internal_malloc) ? NULL : ctx->malloc;
-        retval->free = (ctx->free == internal_free) ? NULL : ctx->free;
     } // else
 
+    retval->malloc = (ctx->malloc == internal_malloc) ? NULL : ctx->malloc;
+    retval->free = (ctx->free == internal_free) ? NULL : ctx->free;
+
     return retval;
 } // build_parsedata