From 87f3451f2d2e992da862bce71816fbeb548513c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Sun, 14 Sep 2014 08:48:07 +0200 Subject: All *_free(...) functions should accept a NULL argument --- editor.c | 2 ++ text.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/editor.c b/editor.c index 455ed5b..e892c09 100644 --- a/editor.c +++ b/editor.c @@ -377,6 +377,8 @@ err: } void editor_free(Editor *ed) { + if (!ed) + return; while (ed->windows) editor_window_close(ed->windows); editor_prompt_free(ed->prompt); diff --git a/text.c b/text.c index 56332db..7338415 100644 --- a/text.c +++ b/text.c @@ -457,6 +457,8 @@ static Change *change_alloc(Text *txt, size_t pos) { } static void change_free(Change *c) { + if (!c) + return; /* only free the new part of the span, the old one is still in use */ piece_free(c->new.start); if (c->new.start != c->new.end) -- cgit v1.2.3