summaryrefslogtreecommitdiff
path: root/sed/debug.c
diff options
context:
space:
mode:
authorJim Meyering <meyering@fb.com>2018-10-27 15:47:41 -0700
committerJim Meyering <meyering@fb.com>2018-10-27 15:47:41 -0700
commit2bfa7984c84caaaedcfb26a13d8c190f490d7cd0 (patch)
tree40837c74191c5d48d47d4d8fcfcc228e60e61034 /sed/debug.c
parent3ac640ce3b896db8605adc25c266334c1fd455dc (diff)
downloadsed-2bfa7984c84caaaedcfb26a13d8c190f490d7cd0.tar.gz
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.
Diffstat (limited to 'sed/debug.c')
-rw-r--r--sed/debug.c9
1 files 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;