strings: Improve code to detect excessively large minimum string lengths.
[binutils-gdb.git] / binutils / deflex.l
index 8c55629d548c92d6bda5211a0d1b5f33e7a28f60..d031538fabc9d4b1f5a09b467038b6fa9d91b38d 100644 (file)
@@ -2,7 +2,7 @@
 
 %{/* deflex.l - Lexer for .def files */
 
-/* Copyright (C) 1995-2017 Free Software Foundation, Inc.
+/* Copyright (C) 1995-2023 Free Software Foundation, Inc.
 
    This file is part of GNU Binutils.
 
@@ -69,14 +69,12 @@ int linenumber;
                }
 
 "\""[^\"]*"\"" {
-               yylval.id = xstrdup (yytext+1);
-               yylval.id[yyleng-2] = 0;
+               yylval.id = xmemdup (yytext + 1, yyleng - 2, yyleng - 1);
                return ID;
                }
 
 "\'"[^\']*"\'" {
-               yylval.id = xstrdup (yytext+1);
-               yylval.id[yyleng-2] = 0;
+               yylval.id = xmemdup (yytext + 1, yyleng - 2, yyleng - 1);
                return ID;
                }
 "*".*          { }