bug-sed
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#33181: sed --debug: fix two problems


From: Jim Meyering
Subject: bug#33181: sed --debug: fix two problems
Date: Sat, 27 Oct 2018 16:00:40 -0700

Hi Assaf,

I built and ran tests on a Fedora 29 beta system
and noticed a failure in the new debug test because
I'd set MALLOC_PERTURB_=13 in my environment.
That exposed what looked like a UMR bug.  I confirmed it by
running under valgrind.  Fixed by the first patch below.

Initially, I didn't even reach the offending code because
that same system lacked perl's Data::Dump module.
That is addressed by the second patch.

Thanks,
Jim

>From 2bfa7984c84caaaedcfb26a13d8c190f490d7cd0 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sat, 27 Oct 2018 15:47:41 -0700
Subject: [PATCH 1/2] sed: avoid UMR in --debug code path

* sed/debug.c (debug_print_function) [b, t, T]: For a b, t or T
command with no LABEL, do not access uninitialized memory.
I.e., print the label name only when there is one.
---
 sed/debug.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/sed/debug.c b/sed/debug.c
index 4eedd40..9ec37b6 100644
--- a/sed/debug.c
+++ b/sed/debug.c
@@ -302,9 +302,12 @@ debug_print_function (const struct vector *program, const 
struct sed_cmd *sc)
     case 't':
     case 'T':
       {
-        const char *label_name = program->v[sc->x.jump_index].x.label_name;
-        if (label_name)
-          printf (" %s", label_name);
+        if (sc->x.jump_index < program->v_length)
+          {
+            const char *label_name = program->v[sc->x.jump_index].x.label_name;
+            if (label_name)
+              printf (" %s", label_name);
+          }
       }
       break;

--
2.18.0


>From 1c0866b1d34c18cfba2cfd20cc915e70fa975cbd Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sat, 27 Oct 2018 15:53:03 -0700
Subject: [PATCH 2/2] tests: avoid unnecessary dependency on Data::Dump

* testsuite/debug.pl: Don't use Data::Dump.  Unnecessary.
That package, perl-Data-Dump, appear not to be default-installed
on at least a Fedora 29 beta system.
---
 testsuite/debug.pl | 1 -
 1 file changed, 1 deletion(-)

diff --git a/testsuite/debug.pl b/testsuite/debug.pl
index 2e4235a..661c5ed 100644
--- a/testsuite/debug.pl
+++ b/testsuite/debug.pl
@@ -18,7 +18,6 @@

 use strict;
 use File::stat;
-use Data::Dump qw(dump);

 (my $program_name = $0) =~ s|.*/||;

--
2.18.0





reply via email to

[Prev in Thread] Current Thread [Next in Thread]