From 58a802fa63c5297009c8382c1ad35af42473c714 Mon Sep 17 00:00:00 2001 From: Chris Allegretta Date: Wed, 4 Feb 2009 19:50:23 +0000 Subject: [PATCH] Fix for precalc_multicolorinfo: make sure we malloc for all the lines we're precalculating, duh. New utility func alloc_multidata_if_needed(). git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4363 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- src/nano.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/nano.c b/src/nano.c index 72cd925e..36843188 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1676,6 +1676,12 @@ int do_mouse(void) #endif /* !DISABLE_MOUSE */ #ifdef ENABLE_COLOR +void alloc_multidata_if_needed(filestruct *fileptr) +{ + if (!fileptr->multidata) + fileptr->multidata = nmalloc(openfile->syntax->nmultis * sizeof(short)); +} + /* Precalculate the multi-line start and end regex info so we can speed up rendering (with any hope at all...) */ void precalc_multicolorinfo(void) @@ -1702,8 +1708,7 @@ void precalc_multicolorinfo(void) for (fileptr = openfile->fileage; fileptr != NULL; fileptr = fileptr->next) { int startx = 0; - if (!fileptr->multidata) - fileptr->multidata = nmalloc(openfile->syntax->nmultis * sizeof(short)); + alloc_multidata_if_needed(fileptr); if ((cur_check = time(NULL)) - last_check > 1) { last_check = cur_check; @@ -1744,8 +1749,10 @@ void precalc_multicolorinfo(void) lines in between and the ends properly */ fileptr->multidata[tmpcolor->id] |= CENDAFTER; for (fileptr = fileptr->next; fileptr != endptr; fileptr = fileptr->next) { + alloc_multidata_if_needed(fileptr); fileptr->multidata[tmpcolor->id] = CWHOLELINE; } + alloc_multidata_if_needed(endptr); endptr->multidata[tmpcolor->id] |= CBEGINBEFORE; } } -- 2.39.5