orccodemem: Fix use-after-free in error paths
authorBastien Nocera <hadess@hadess.net>
Fri, 6 May 2022 13:56:17 +0000 (15:56 +0200)
committerBastien Nocera <hadess@hadess.net>
Fri, 6 May 2022 13:56:17 +0000 (15:56 +0200)
commit03d9f144cb333057bb203cbecea3fc29bb336120
tree2d12b9231f4d4a4f1bd84684b5e5b6d608adbeb4
parent61125caa52c53b62ccc889e672117eb47c67e13e
orccodemem: Fix use-after-free in error paths

In file included from gstreamer/subprojects/orc/orc/orc.h:7,
                 from gstreamer/subprojects/orc/orc/orcprogram.h:5,
                 from gstreamer/subprojects/orc/orc/orccodemem.c:30:
gstreamer/subprojects/orc/orc/orccodemem.c: In function ‘orc_code_region_allocate_codemem_dual_map.constprop’:
gstreamer/subprojects/orc/orc/orcdebug.h:138:3: warning: pointer ‘filename’ may be used after ‘free’ [-Wuse-after-free]
  138 |   orc_debug_print((level), __FILE__, ORC_FUNCTION, __LINE__, __VA_ARGS__); \
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gstreamer/subprojects/orc/orc/orcdebug.h:92:26: note: in expansion of macro ‘ORC_DEBUG_PRINT’
   92 | #define ORC_WARNING(...) ORC_DEBUG_PRINT(ORC_DEBUG_WARNING, __VA_ARGS__)
      |                          ^~~~~~~~~~~~~~~
gstreamer/subprojects/orc/orc/orccodemem.c:252:5: note: in expansion of macro ‘ORC_WARNING’
  252 |     ORC_WARNING ("failed to create write map '%s'. err=%i", filename, errno);
      |     ^~~~~~~~~~~
gstreamer/subprojects/orc/orc/orccodemem.c:234:3: note: call to ‘free’ here
  234 |   free (filename);
      |   ^~~~~~~~~~~~~~~
gstreamer/subprojects/orc/orc/orcdebug.h:138:3: warning: pointer ‘filename’ may be used after ‘free’ [-Wuse-after-free]
  138 |   orc_debug_print((level), __FILE__, ORC_FUNCTION, __LINE__, __VA_ARGS__); \
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gstreamer/subprojects/orc/orc/orcdebug.h:92:26: note: in expansion of macro ‘ORC_DEBUG_PRINT’
   92 | #define ORC_WARNING(...) ORC_DEBUG_PRINT(ORC_DEBUG_WARNING, __VA_ARGS__)
      |                          ^~~~~~~~~~~~~~~
gstreamer/subprojects/orc/orc/orccodemem.c:245:5: note: in expansion of macro ‘ORC_WARNING’
  245 |     ORC_WARNING("failed to create exec map '%s'. err=%i", filename, errno);
      |     ^~~~~~~~~~~
gstreamer/subprojects/orc/orc/orccodemem.c:234:3: note: call to ‘free’ here
  234 |   free (filename);
      |   ^~~~~~~~~~~~~~~

Fixes: bb5fcb31 ("orccodemem: Report errno during failures to create mmap codemap.")
orc/orccodemem.c