commit 8cbd4cb67f1fd58066620194980635d2b97a3348
parent 07e2589f803a0af548c04ce741e4352c2e5c6f3b
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date: Thu, 4 Nov 2004 15:31:43 +0000
avoid potential segfaults while unpartitioning a filestruct
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2057 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/nano.c b/src/nano.c
@@ -674,7 +674,8 @@ void unpartition_filestruct(partition *p)
* with it. */
tmp = mallocstrcpy(NULL, fileage->data);
fileage->prev = p->top_prev;
- fileage->prev->next = fileage;
+ if (fileage->prev != NULL)
+ fileage->prev->next = fileage;
fileage->data = charealloc(fileage->data, strlen(p->top_data) +
strlen(fileage->data) + 1);
strcpy(fileage->data, p->top_data);
@@ -686,7 +687,8 @@ void unpartition_filestruct(partition *p)
* the text after bot_x from bot_data. Free bot_data when we're
* done with it. */
filebot->next = p->bot_next;
- filebot->next->prev = filebot;
+ if (filebot->next != NULL)
+ filebot->next->prev = filebot;
filebot->data = charealloc(filebot->data, strlen(filebot->data) +
strlen(p->bot_data) + 1);
strcat(filebot->data, p->bot_data);