nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nano-devel] Patch to files.c:read_file


From: David Benbennick
Subject: [Nano-devel] Patch to files.c:read_file
Date: Tue, 26 Mar 2002 03:14:38 -0500 (EST)

Using any version of nano with files.c,v 1.155 and any compile options,
opening a 0-byte file causes a seg fault.  Specifically, do

rm somefile
touch somefile
nano somefile
<Type anything>

Attached is a patch fixing that problem.

On Thu, 21 Mar 2002, Chris Allegretta wrote:    <snip>
> In all versions of nano, attempting to insert a file of 0 bytes would
> cause nano to go into an infinite loop ...

In fixing the seg fault above, I restored the infinite loop problem, and
spent hours fixing it.  Thus, the patch above also has two "assert"
statements added to nano.c.  The asserts guard against that loop, which
happened in nano.c:renumber_all.

That takes me to a final point.  The assert statement is not tested if
NDEBUG is defined.  Most users probably should not have asserts, since
they test impossible conditions.  Thus, maybe we should add a line like

AC_DEFINE(NDEBUG)

to configure.ac.  (I haven't tested this since I don't have autoconf
2.52.)


David

Attachment: 26mar02:37.diff
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]