foxygit / doom Log in
commit 6969f6d8f08dce89e16373b53fa12f3a4cbe7f5c
Author:     Roman Fomin <rfomin@gmail.com>
AuthorDate: Mon Feb 19 17:40:00 2024 +0700
Commit:     GitHub <noreply@github.com>
CommitDate: Mon Feb 19 11:40:00 2024 +0100

    Fix ASAN report about use after free (#1667)

    `GetTargetForAddr` can invalidate pointers because of the use of `realloc`. Get
    element from the `targets` array again.
---
 src/net_query.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/net_query.c b/src/net_query.c
index 3fe2cc2a..d9c8b2d9 100644
--- a/src/net_query.c
+++ b/src/net_query.c
@@ -323,6 +323,7 @@ static void NET_Query_ParseResponse(net_addr_t *addr, net_packet_t *packet,
         // Create new target.

         target = GetTargetForAddr(addr, true);
+        broadcast_target = GetTargetForAddr(NULL, false);
         target->state = QUERY_TARGET_QUERIED;
         target->query_time = broadcast_target->query_time;
     }