From 4ef4a3097fbdf5f0a13d3f5b3e60cdbb02fe1671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Tue, 20 Sep 2011 17:04:54 +0000 Subject: fixed crash when add2 to an empty buffer heopfully also fixed bug when append2 an empty buffer svn path=/trunk/externals/zexy/; revision=15318 --- src/msgfile.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/msgfile.c b/src/msgfile.c index 1d6224c..dd772fe 100644 --- a/src/msgfile.c +++ b/src/msgfile.c @@ -410,9 +410,13 @@ static void msgfile_add(t_msgfile *x, t_symbol *s, int ac, t_atom *av) static void msgfile_add2(t_msgfile *x, t_symbol *s, int ac, t_atom *av) { msgfile_end(x); - if (x->current->previous) x->current = x->current->previous; + if (x->current) { + if(x->current->previous) x->current = x->current->previous; + } else { + add_currentnode(x); + } write_currentnode(x, ac, av); - if (x->current->next) { + if (x->current && x->current->next) { x->previous= x->current; x->current = x->current->next; } @@ -424,6 +428,9 @@ static void msgfile_append(t_msgfile *x, t_symbol *s, int ac, t_atom *av) } static void msgfile_append2(t_msgfile *x, t_symbol *s, int ac, t_atom *av) { + if(!x->current) + add_currentnode(x); + if (x->current->thislist) write_currentnode(x, ac, av); else msgfile_append(x, s, ac, av); } -- cgit v1.2.1