dae4e0aa5ea2ca7d8322580278a017d31230138b markd Wed Feb 2 23:33:05 2011 -0800 fixed memory corruption on very long GFF attribute columns (#2694) diff --git src/lib/gff.c src/lib/gff.c index 6fa5e41..ee2c75f 100644 --- src/lib/gff.c +++ src/lib/gff.c @@ -1,26 +1,27 @@ /* gff - routines to read many types of gff and gtf files * and turn them into a relatively easy to deal with form * in memory. * * This file is copyright 2002 Jim Kent, but license is hereby * granted for all use - public, private or commercial. */ #include "common.h" #include "hash.h" #include "linefile.h" #include "gff.h" #include "obscure.h" +#include "dystring.h" static char const rcsid[] = "$Id: gff.c,v 1.24 2009/02/05 20:53:24 hiram Exp $"; void gffGroupFree(struct gffGroup **pGroup) /* Free up a gffGroup including lineList. */ { struct gffGroup *group; if ((group = *pGroup) != NULL) { slFreeList(&group->lineList); freez(pGroup); } } void gffGroupFreeList(struct gffGroup **pList) @@ -80,38 +81,41 @@ if (diff == 0) diff = a->end - b->end; return diff; } static void gffSyntaxError(char *fileName, int line, char *msg) /* Complain about syntax error in GFF file. */ { errAbort("%s Bad line %d of %s:\n", msg, line, fileName); } static char *gffTnName(char *seqName, char *groupName) /* Make name that encorperates seq and group names.... */ { -static char nameBuf[512]; +static struct dyString *nameBuf = NULL; +if (nameBuf == NULL) + nameBuf = dyStringNew(0); +dyStringClear(nameBuf); if (startsWith("gene-", groupName)) groupName += 5; if (startsWith("cc_", groupName)) groupName += 3; -strcpy(nameBuf, groupName); +dyStringAppend(nameBuf, groupName); -return nameBuf; +return nameBuf->string; } static boolean isGtfGroup(char *group) /* Return TRUE if group field looks like GTF */ { if (strstr(group, "gene_id") == NULL) return FALSE; if (countChars(group, '"') >= 2) return TRUE; if (strstr(group, "transcript_id") != NULL) return TRUE; return FALSE; } boolean gffHasGtfGroup(char *line)