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.
This commit is contained in:
Jim Meyering committed 2018-10-27 15:47:41 -07:00
1 parent 3ac640ce3b
commit 2bfa7984c8
1 file changed
+6 -3
+6 -3
View File
@@ -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;