Work around a -Wuse-after-free misdetection in GCC 12
commite61d1504456b80121837acb23549bf630c0a19df
authorPetr Písař <petr.pisar@atlas.cz>
Sun, 30 Jan 2022 09:17:36 +0000 (30 10:17 +0100)
committerPetr Písař <petr.pisar@atlas.cz>
Sun, 30 Jan 2022 09:21:55 +0000 (30 10:21 +0100)
tree9225b6502fc92edca33b038d338c44111ffae14a
parentce92ec266ccccc90b7a8cb0264b997dab27c10f9
Work around a -Wuse-after-free misdetection in GCC 12

GCC 12 enabled more optimizitions and started to emmit a false warning:

libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I.. -I/usr/include/libxml2 -DLOCALEDIR=\"/usr/share/locale\" -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Werror -std=c99 -Wall -c isds.c  -fPIC -DPIC -o .libs/libisds_la-isds.o
isds.c: In function 'build_send_check_dbdummy_request.part.0.constprop.0':
isds.c:5186:5: error: pointer 'request_35' used after 'free' [-Werror=use-after-free]
 5186 |     xmlFreeNode(request);
      |     ^~~~~~~~~~~~~~~~~~~~
isds.c:5185:5: note: call to 'free' here
 5185 |     free(service_name_locale);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~

This patch simplifies a code path not to trigger the warning.

<https://bugzilla.redhat.com/show_bug.cgi?id=2047715>
src/isds.c