From 7a5e097160bec3d67d7bbe3c518cb1cda6fabb0a Mon Sep 17 00:00:00 2001 From: Hoorad Farrokh Date: Sun, 13 Oct 2024 14:28:38 +1300 Subject: [PATCH] Fixed potential nullpointer de-reference in the buffer-get-bline-w-hint function --- buffer.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/buffer.c b/buffer.c index 27eb500..95394de 100644 --- a/buffer.c +++ b/buffer.c @@ -702,6 +702,10 @@ int buffer_get_bline_w_hint(buffer_t *self, bint_t line_index, bline_t *opt_hint if (!opt_hint) { opt_hint = self->first_line; + if (!opt_hint) { // Satisfy scan-build lint + *ret_bline = NULL; + return MLBUF_ERR; + } } fwd = opt_hint; @@ -1406,6 +1410,11 @@ static int _buffer_redo(buffer_t *self, int by_group) { // Get line to perform undo on bline = NULL; buffer_get_bline(self, action_to_redo->start_line_index, &bline); + + if (!bline){ + return MLBUF_ERR; + } + MLBUF_BLINE_ENSURE_CHARS(bline); if (!bline) { return MLBUF_ERR;