glibc/backport-elf-tlsdeschtab.h-Add-the-Malloc-return-value-check.patch
shixuantong 0a6899cbaa sync patches from upstream community
(cherry picked from commit 728e1f1f679b5177ba8e35972e119cea66aa1694)
2022-12-09 14:48:47 +08:00

33 lines
1.0 KiB
Diff

From d1d0162e50afe7fa1e2fc4a901eb411db48acd7b Mon Sep 17 00:00:00 2001
From: Xiaoming Ni <nixiaoming@huawei.com>
Date: Fri, 4 Nov 2022 17:30:00 +0800
Subject: [PATCH] elf/tlsdeschtab.h: Add the Malloc return value check in
_dl_make_tlsdesc_dynamic()
Check the return value of malloc based on the function header comment of
_dl_make_tlsdesc_dynamic(). If the return value fails, NULL is
returned.
Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>
Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
---
elf/tlsdeschtab.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/elf/tlsdeschtab.h b/elf/tlsdeschtab.h
index 85bd0415..2de61737 100644
--- a/elf/tlsdeschtab.h
+++ b/elf/tlsdeschtab.h
@@ -111,6 +111,8 @@ _dl_make_tlsdesc_dynamic (struct link_map *map, size_t ti_offset)
}
*entry = td = malloc (sizeof (struct tlsdesc_dynamic_arg));
+ if (! td)
+ return 0;
/* This may be higher than the map's generation, but it doesn't
matter much. Worst case, we'll have one extra DTV update per
thread. */
--
2.33.0