aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2023-10-09 17:52:39 +0100
committerNick Clifton <nickc@redhat.com>2023-10-09 17:52:39 +0100
commit1b334e27f8410c7fbe3417023258eb9e03ec9592 (patch)
treed038ef33d9ce58e516e16c603d9d60a36810ef7b
parentee1cb49e5a9de8049d887abd8c9f2eff1851147e (diff)
downloadgdb-1b334e27f8410c7fbe3417023258eb9e03ec9592.zip
gdb-1b334e27f8410c7fbe3417023258eb9e03ec9592.tar.gz
gdb-1b334e27f8410c7fbe3417023258eb9e03ec9592.tar.bz2
Fix: Null pointer dereference in ldlex.l
PR 30951 * ldlex.l (yy_input): Check for YY_CURRENT_BUFFER being NULL.
-rw-r--r--ld/ChangeLog3
-rw-r--r--ld/ldlex.l2
2 files changed, 4 insertions, 1 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 8423dd4..05b88ee 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,5 +1,8 @@
2023-10-09 Nick Clifton <nickc@redhat.com>
+ 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 435172c..94b2ea7 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)
{