Fix null pointer dereference vulnerability in pv_dup function

Message ID 20260327073626.532887-2-pengxu@kylinos.cn
State New
Headers
Series Fix null pointer dereference vulnerability in pv_dup function |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm success Test passed

Commit Message

pengxu@kylinos.cn March 27, 2026, 7:36 a.m. UTC
  From: pengxu2024 <pengxu@kylinos.cn>

---
 opcodes/opc2c.c | 2 ++
 1 file changed, 2 insertions(+)
  

Patch

diff --git a/opcodes/opc2c.c b/opcodes/opc2c.c
index 5e5fba67add..f66877fbcc4 100644
--- a/opcodes/opc2c.c
+++ b/opcodes/opc2c.c
@@ -462,6 +462,8 @@  pv_dup (char * p, char * ep)
 {
   int n = ep - p;
   char *rv = (char *) malloc (n + 1);
+  if (rv == NULL)
+    return NULL;
 
   memcpy (rv, p, n);
   rv[n] = 0;