summaryrefslogtreecommitdiffstats
path: root/linenoise
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-02-26 08:27:04 -0800
committerKaz Kylheku <kaz@kylheku.com>2019-02-26 08:27:04 -0800
commit5f131a787efcda109e405fe99104626bc912194d (patch)
tree64b880fc0ea45f0d80fb2134e0eb42718613ae5d /linenoise
parenta712268af12b40874fe3fe142e14b329e42c20e2 (diff)
downloadtxr-5f131a787efcda109e405fe99104626bc912194d.tar.gz
txr-5f131a787efcda109e405fe99104626bc912194d.tar.bz2
txr-5f131a787efcda109e405fe99104626bc912194d.zip
linenoise: defensive null pointer check.
* linenoise/linenoise.c (move_cursor_multiline): If the npos argument happens to be equal to the current position (the operation is a null move), then no movement is generated. In that case, no ab_append operation is called, and ab.b will stay null; this null pointer then gets passed to lino_os.puts_fn as the string to output, and that will blow up. This situation hasn't actually been observed.
Diffstat (limited to 'linenoise')
-rw-r--r--linenoise/linenoise.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c
index cb4b9f41..50e44e00 100644
--- a/linenoise/linenoise.c
+++ b/linenoise/linenoise.c
@@ -1272,7 +1272,8 @@ static void move_cursor_multiline(lino_t *l, int npos)
ab_append(&ab, seq, wcslen(seq));
}
- (void) lino_os.puts_fn(l->tty_ofs, ab.b);
+ if (ab.b)
+ (void) lino_os.puts_fn(l->tty_ofs, ab.b);
ab_free(&ab);
l->dpos = npos;
l->oldrow = nrow;