aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2007-09-06 08:31:08 +0000
committerIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2007-09-06 08:31:08 +0000
commitb4800800242cc3fe81e567180a1a4094f78b3495 (patch)
tree4a6c4f4ff29514b2fa46824c7d19ca5a53d34e5d /src
parentb0950b3d98002d5c7870e0a33704d94cf24abfc7 (diff)
fixed crasher bug when replacing an sublist in an empty msgbox
svn path=/trunk/externals/zexy/; revision=8707
Diffstat (limited to 'src')
-rw-r--r--src/msgfile.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/msgfile.c b/src/msgfile.c
index 9cb209c..7a2b2fb 100644
--- a/src/msgfile.c
+++ b/src/msgfile.c
@@ -63,7 +63,6 @@ typedef struct _msgfile
int mode;
-
t_msglist *current; /* pointer to our list */
t_symbol *x_dir;
@@ -118,14 +117,16 @@ static void delete_currentnode(t_msgfile *x)
t_msglist *dummy = x->current;
t_msglist *nxt=dummy->next;
t_msglist *prv=dummy->previous;
- freebytes(dummy->thislist, sizeof(dummy->thislist));
- dummy->thislist = 0;
- dummy->n = 0;
- dummy->next=0;
- dummy->previous=0;
-
- freebytes(dummy, sizeof(t_msglist));
- dummy=0;
+ if(dummy){
+ freebytes(dummy->thislist, sizeof(dummy->thislist));
+ dummy->thislist = 0;
+ dummy->n = 0;
+ dummy->next=0;
+ dummy->previous=0;
+
+ freebytes(dummy, sizeof(t_msglist));
+ dummy=0;
+ }
if (nxt) nxt->previous = prv;
if (prv) prv->next = nxt;
@@ -355,9 +356,15 @@ static void msgfile_set(t_msgfile *x, t_symbol *s, int ac, t_atom *av)
static void msgfile_replace(t_msgfile *x, t_symbol *s, int ac, t_atom *av)
{
- freebytes(x->current->thislist, sizeof(x->current->thislist));
- x->current->thislist = 0;
- x->current->n = 0;
+ if(x->current) {
+ if(x->current->thislist) {
+ freebytes(x->current->thislist, sizeof(x->current->thislist));
+ }
+ x->current->thislist = 0;
+ x->current->n = 0;
+ } else {
+ add_currentnode(x);
+ }
write_currentnode(x, ac, av);
}