aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--binutils/deflex.l6
-rw-r--r--gas/as.h4
-rw-r--r--ld/ldlex.l16
3 files changed, 7 insertions, 19 deletions
diff --git a/binutils/deflex.l b/binutils/deflex.l
index 1f3ba65..def908c 100644
--- a/binutils/deflex.l
+++ b/binutils/deflex.l
@@ -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;
}
"*".* { }
diff --git a/gas/as.h b/gas/as.h
index 14a768f..f3f12fb 100644
--- a/gas/as.h
+++ b/gas/as.h
@@ -484,9 +484,7 @@ void add_debug_prefix_map (const char *);
static inline char *
xmemdup0 (const char *in, size_t len)
{
- char *out = (char *) xmalloc (len + 1);
- out[len] = 0;
- return (char *) memcpy (out, in, len);
+ return xmemdup (in, len, len + 1);
}
struct expressionS;
diff --git a/ld/ldlex.l b/ld/ldlex.l
index 6aeba6d..5db1e73 100644
--- a/ld/ldlex.l
+++ b/ld/ldlex.l
@@ -431,18 +431,10 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)*
}
<SCRIPT,EXPRESSION,WILD,VERS_NODE,INPUTLIST>"\""[^\"]*"\"" {
- /* No matter the state, quotes
- give what's inside. */
- bfd_size_type len;
- yylval.name = xstrdup (yytext + 1);
- /* PR ld/20906. A corrupt input file
- can contain bogus strings. */
- len = strlen (yylval.name);
- if (len > (bfd_size_type) yyleng - 2)
- len = yyleng - 2;
- yylval.name[len] = 0;
- return NAME;
- }
+ /* No matter the state, quotes give what's inside. */
+ yylval.name = xmemdup (yytext + 1, yyleng - 2, yyleng - 1);
+ return NAME;
+ }
<SCRIPT,EXPRESSION,WILD,VERS_START,VERS_NODE,VERS_SCRIPT,INPUTLIST>"\n" {
lineno++; }