From 42ac5368e1505094dd006418f049e2b8b1d80b92 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Mon, 30 Nov 2015 16:44:44 +0000 Subject: [PATCH] Allowing an array parameter to be NULL. This fixes Savannah bug #46420. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5457 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 2 ++ src/browser.c | 3 +-- src/files.c | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6f6628c7..df063290 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,8 @@ * src/text.c (add_undo, update_undo, do_undo, do_redo), src/nano.h: Store and retrieve the correct file size before and after an action. This fixes Savannah bug #45523. + * src/files.c (free_chararray): Allow the parameter to be NULL. + This fixes Savannah bug #46420. 2015-11-29 Benno Schulenberg * src/color.c (reset_multis): Evaluate correctly whether to reset diff --git a/src/browser.c b/src/browser.c index eb6119ac..25d24402 100644 --- a/src/browser.c +++ b/src/browser.c @@ -460,8 +460,7 @@ void browser_init(const char *path, DIR *dir) rewinddir(dir); - if (filelist != NULL) - free_chararray(filelist, filelist_len); + free_chararray(filelist, filelist_len); filelist_len = i; diff --git a/src/files.c b/src/files.c index 220f978d..4631cd2f 100644 --- a/src/files.c +++ b/src/files.c @@ -2553,7 +2553,8 @@ int diralphasort(const void *va, const void *vb) * elements. */ void free_chararray(char **array, size_t len) { - assert(array != NULL); + if (array == NULL) + return; for (; len > 0; len--) free(array[len - 1]);