QRegExpMatchState: do not store a stale pointer


Axivion analyzer complained about the class member 'in' storing the
address of a local variable 'char_null' even when the variable goes
out of scope, which can lead to use-after-free.

A further examination of the code shows that even when 'char_null'
is not used, the code was storing the incoming 'str0' pointer in
the same member variable 'in'. We can assume that 'str0' is available
during the execution of the match() function, but we cannot make
such assumptions after the execution is done. So, storing the pointer
to str0 unconditionally can also lead to use-after-free.

In practice none of the two cases causes any issues, because the
member variable 'in' is only used within the match() function, and
the helper functions that are called from it.

However, this patch chooses an approach of explicitly resetting 'in'
to nullptr once it is not used anymore. It also uses NSDMI to
initialize 'in' with the nullptr.

Note: surely, resetting to nullptr itself does not fix any crashes, but
it provides a reliable way to distinguish between an initialized and
uninitialized variable.

Axivion-Id: qt_Add-ons_qt5compat_dev_linux:SV32
Fixes: QTBUG-144753
Pick-to: 6.12 6.11 6.8
Change-Id: I318063bf7dd97f52cb157c2eb7c60f3723d80248
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
commitb1e73741f54b2c7c6d6c7e96a05f990496e525df
parent8c177c8ae0d00daf9c5dae7954fc15bdf6bab153
authorIvan Solovev <ivan.solovev@qt.io>
committerIvan Solovev <ivan.solovev@qt.io>
commit timeTue, 16 Jun 2026 07:50:38 +0000