From 2bfa7984c84caaaedcfb26a13d8c190f490d7cd0 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 27 Oct 2018 15:47:41 -0700 Subject: [PATCH] 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;