resolve: fix potential memleak and use-after-free
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 5 Feb 2022 12:37:01 +0000 (21:37 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 8 Feb 2022 08:35:53 +0000 (17:35 +0900)
commit73bfd7be042cc63e7649242b377ad494bf74ea4b
tree36fb589c212165b2e387198f98599416b77c0ce6
parentec82f867eea000921fa0f93a9adf1f8fd7bfe2c5
resolve: fix potential memleak and use-after-free

When stub stream is closed early, then queries associated to the stream
are freed. Previously, the timer event source for queries may not be
disabled, hence may be triggered with already freed query.
See also dns_stub_stream_complete().

Note that we usually not set NULL or zero when freeing simple objects.
But, here DnsQuery is large and complicated object, and the element may
be referenced in subsequent freeing process in the future. Hence, for
safety, let's set NULL to the pointer.
src/resolve/resolved-dns-query.c