From 1b334e27f8410c7fbe3417023258eb9e03ec9592 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Mon, 9 Oct 2023 17:52:39 +0100 Subject: [PATCH] Fix: Null pointer dereference in ldlex.l PR 30951 * ldlex.l (yy_input): Check for YY_CURRENT_BUFFER being NULL. --- ld/ChangeLog | 3 +++ ld/ldlex.l | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ld/ChangeLog b/ld/ChangeLog index 8423dd4ac29..05b88ee0b94 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,5 +1,8 @@ 2023-10-09 Nick Clifton + PR 30951 + * ldlex.l (yy_input): Check for YY_CURRENT_BUFFER being NULL. + PR 30954 * ldlang.c (map_input_to_output_sections): Check that os is non NULL before using it. diff --git a/ld/ldlex.l b/ld/ldlex.l index 435172c08c3..94b2ea70acd 100644 --- a/ld/ldlex.l +++ b/ld/ldlex.l @@ -668,7 +668,7 @@ static int yy_input (char *buf, int max_size) { int result = 0; - if (YY_CURRENT_BUFFER->yy_input_file) + if (YY_CURRENT_BUFFER != NULL && YY_CURRENT_BUFFER->yy_input_file) { if (yyin) { -- 2.30.2