From ab7c39fddb1627f593483075ed05165a42f26db0 Mon Sep 17 00:00:00 2001 From: Ilya Ivanov Date: Thu, 27 Apr 2017 15:06:56 +0300 Subject: [PATCH] Check for variable being non-NULL before using it The "buffer" argument can apparently be null, as there is a check for this on the next line, but it was used without checking that this is the case. Fix this, although it's not totally clear if "buffer" can really be null at all and maybe the check below should have been removed instead -- but prefer to err on the side of caution. Thanks to PVS-Studio for finding this issue (V595 The 'buffer' pointer was utilized before it was verified against nullptr). --- src/richtext/richtextbuffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp index 8f17c6a430..a9e14037fb 100644 --- a/src/richtext/richtextbuffer.cpp +++ b/src/richtext/richtextbuffer.cpp @@ -9932,7 +9932,7 @@ bool wxRichTextCell::EditProperties(wxWindow* parent, wxRichTextBuffer* buffer) wxRichTextAttr attr; wxRichTextSelection sel; - if (buffer->GetRichTextCtrl()) + if (buffer && buffer->GetRichTextCtrl()) sel = buffer->GetRichTextCtrl()->GetSelection(); if (table && buffer && buffer->GetRichTextCtrl() && sel.IsValid() &&