orc: Don't set memory protection if there's no code
authorNirbheek Chauhan <nirbheek@centricular.com>
Thu, 2 Jul 2020 09:32:57 +0000 (15:02 +0530)
committerNirbheek Chauhan <nirbheek@centricular.com>
Thu, 2 Jul 2020 09:32:57 +0000 (15:02 +0530)
If the size of the JIT code is 0, there's no code and the *mem is
uninitialized. This can happen when orcc.exe is used to generate
backup C code.

Part-of: <https://gitlab.freedesktop.org/gstreamer/orc/-/merge_requests/44>

orc/orccompiler.c

index 23a1a84..63eee29 100644 (file)
@@ -223,6 +223,9 @@ _set_virtual_protect (void * mem, size_t size, int code_protect)
   char *msg;
   DWORD old_protect;
 
+  /* No code, so we 'succeed' */
+  if (size == 0)
+    return TRUE;
 
   if (!mem)
     return FALSE;