Skip to content

orc: Fix potential use-after-free in error cases

Nirbheek Chauhan requested to merge nirbheek/orc:use-after-free-warning into master
In file included from ../subprojects/orc/orc/orc.h:7,
                 from ../subprojects/orc/orc/orcprogram.h:5,
                 from ../subprojects/orc/orc/orccodemem.c:30:
../subprojects/orc/orc/orccodemem.c: In function ‘orc_code_region_allocate_codemem_dual_map.constprop’:
../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__); \
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../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__)
      |                          ^~~~~~~~~~~~~~~
../subprojects/orc/orc/orccodemem.c:250:5: note: in expansion of macro ‘ORC_WARNING’
  250 |     ORC_WARNING ("failed to create write map '%s'. err=%i", filename, errno);
      |     ^~~~~~~~~~~
../subprojects/orc/orc/orccodemem.c:234:3: note: call to ‘free’ here
  234 |   free (filename);
      |   ^~~~~~~~~~~~~~~
../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__); \
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../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__)
      |                          ^~~~~~~~~~~~~~~
../subprojects/orc/orc/orccodemem.c:244:5: note: in expansion of macro ‘ORC_WARNING’
  244 |     ORC_WARNING("failed to create exec map '%s'. err=%i", filename, errno);
      |     ^~~~~~~~~~~
../subprojects/orc/orc/orccodemem.c:234:3: note: call to ‘free’ here
  234 |   free (filename);
      |   ^~~~~~~~~~~~~~~

Merge request reports

Loading