aboutsummaryrefslogtreecommitdiff
path: root/gas/read.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2022-02-16 10:30:46 +1030
committerAlan Modra <amodra@gmail.com>2022-02-16 22:05:24 +1030
commit969f6a63c0ae7779fd5eb10af25fd4ab810feef8 (patch)
tree625eb0e11e3609d8e2fc3605ff718811879d266f /gas/read.c
parent8b14b0cb997af3207865b342137007b406259786 (diff)
downloadgdb-969f6a63c0ae7779fd5eb10af25fd4ab810feef8.zip
gdb-969f6a63c0ae7779fd5eb10af25fd4ab810feef8.tar.gz
gdb-969f6a63c0ae7779fd5eb10af25fd4ab810feef8.tar.bz2
ubsan: s_app_line integer overflow
There are quite a few ubsan warnings in gas. This one disappears with a code tidy. * read.c (s_app_line): Rename 'l' to 'linenum'. Avoid ubsan warning.
Diffstat (limited to 'gas/read.c')
-rw-r--r--gas/read.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/gas/read.c b/gas/read.c
index 523708f..f363562 100644
--- a/gas/read.c
+++ b/gas/read.c
@@ -2068,20 +2068,18 @@ void
s_app_line (int appline)
{
char *file = NULL;
- int l;
+ int linenum;
/* The given number is that of the next line. */
if (appline)
- l = get_absolute_expression ();
- else if (!get_linefile_number (&l))
+ linenum = get_absolute_expression ();
+ else if (!get_linefile_number (&linenum))
{
ignore_rest_of_line ();
return;
}
- l--;
-
- if (l < -1)
+ if (linenum < 0)
/* Some of the back ends can't deal with non-positive line numbers.
Besides, it's silly. GCC however will generate a line number of
zero when it is pre-processing builtins for assembler-with-cpp files:
@@ -2092,7 +2090,7 @@ s_app_line (int appline)
in the GCC and GDB testsuites. So we check for negative line numbers
rather than non-positive line numbers. */
as_warn (_("line numbers must be positive; line number %d rejected"),
- l + 1);
+ linenum);
else
{
int flags = 0;
@@ -2152,10 +2150,11 @@ s_app_line (int appline)
if (appline || file)
{
- new_logical_line_flags (file, l, flags);
+ linenum--;
+ new_logical_line_flags (file, linenum, flags);
#ifdef LISTING
if (listing)
- listing_source_line (l);
+ listing_source_line (linenum);
#endif
}
}