[prev in list] [next in list] [prev in thread] [next in thread] 

List:       nano-devel
Subject:    Re: [Nano-devel] [PATCH] Fix segfault when creating a new buffer
From:       Marco_Diego_Aurélio_Mesquita <marcodiegomesquita () gmail ! com>
Date:       2017-10-27 20:40:27
Message-ID: CAE_m23m=epf-VsaVvhO63Ax5ApwgfS1nVGrJ+WCwj0M-fvPUkQ () mail ! gmail ! com
[Download RAW message or body]

On Fri, Oct 27, 2017 at 4:20 PM, David Ramsey <pooka109@gmail.com> wrote:

> The check for text's being an empty string could be simpler.  Instead of:
>
> +    if (!strlen(text))
> +       return;
>
> you should do this, as it doesn't require an extra function call:
>
> +    if (text[0] == '\0')
> +       return;
>

Thanks! Attached is an updated version.

["0001-Fix-segfault-when-creating-a-new-empty-buffer.patch" (text/x-patch)]

From 71c93e5f0b6bab68aa69de0806b35d0e36c2001e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marco Diego Aurélio Mesquita? <marcodiegomesquita@gmail.com>
Date: Fri, 27 Oct 2017 14:03:20 -0300
Subject: [PATCH] Fix segfault when creating a new empty buffer.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
---
 src/history.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/history.c b/src/history.c
index 11cf6c2..3c19991 100644
--- a/src/history.c
+++ b/src/history.c
@@ -81,6 +81,9 @@ void update_history(filestruct **item, const char *text)
 {
     filestruct **htop = NULL, **hbot = NULL, *thesame;

+    if (text[0] == '\0')
+	return;
+
     if (*item == search_history) {
 	htop = &searchtop;
 	hbot = &searchbot;
--
2.7.4



_______________________________________________
Nano-devel mailing list
Nano-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/nano-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic