From d2a78bd9f9a91edef775ab4d7d4cfe4739e718b1 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Wed, 27 Dec 2017 01:44:37 +0000 Subject: [PATCH] add some checks to buffer code --- mutt/buffer.c | 9 +++++++++ mutt/string.c | 2 ++ 2 files changed, 11 insertions(+) diff --git a/mutt/buffer.c b/mutt/buffer.c index 0a703dfa0..2288c575d 100644 --- a/mutt/buffer.c +++ b/mutt/buffer.c @@ -44,6 +44,7 @@ #include #include #include "buffer.h" +#include "debug.h" #include "memory.h" #include "string2.h" @@ -73,6 +74,8 @@ struct Buffer *mutt_buffer_new(void) */ struct Buffer *mutt_buffer_init(struct Buffer *b) { + if (!b) + return NULL; memset(b, 0, sizeof(struct Buffer)); return b; } @@ -86,6 +89,8 @@ struct Buffer *mutt_buffer_init(struct Buffer *b) */ void mutt_buffer_reset(struct Buffer *b) { + if (!b) + return; memset(b->data, 0, b->dsize); b->dptr = b->data; } @@ -212,6 +217,8 @@ int mutt_buffer_printf(struct Buffer *buf, const char *fmt, ...) */ void mutt_buffer_addstr(struct Buffer *buf, const char *s) { + if (!buf || !s) + return; mutt_buffer_add(buf, s, mutt_str_strlen(s)); } @@ -224,5 +231,7 @@ void mutt_buffer_addstr(struct Buffer *buf, const char *s) */ void mutt_buffer_addch(struct Buffer *buf, char c) { + if (!buf) + return; mutt_buffer_add(buf, &c, 1); } diff --git a/mutt/string.c b/mutt/string.c index fe3762ab2..3db74db58 100644 --- a/mutt/string.c +++ b/mutt/string.c @@ -68,8 +68,10 @@ #include #include #include +#include #include #include +#include #include "debug.h" #include "memory.h" #include "string2.h" -- 2.40.0