f107043f550375c5bb08bd6ccb8ac8c8e821da3b braney Wed Feb 13 18:37:18 2013 -0800 fix problem with lmCloneString not handling a NULL input correctly (#10199) diff --git src/lib/localmem.c src/lib/localmem.c index c6fdaa4..50f62a1 100644 --- src/lib/localmem.c +++ src/lib/localmem.c @@ -136,30 +136,39 @@ } char *lmCloneStringZ(struct lm *lm, char *string, int size) /* Return local mem copy of string. */ { if (string == NULL) return NULL; else { char *s = lmAlloc(lm, size+1); memcpy(s, string, size); return s; } } +char *lmCloneString(struct lm *lm, char *string) +/* Return local mem copy of string. */ +{ +if (string == NULL) + return NULL; +else + return lmCloneStringZ(lm, string, strlen(string)); +} + char *lmCloneFirstWord(struct lm *lm, char *line) /* Clone first word in line */ { char *startFirstWord = skipLeadingSpaces(line); if (startFirstWord == NULL) return NULL; char *endFirstWord = skipToSpaces(startFirstWord); if (endFirstWord == NULL) return lmCloneString(lm, startFirstWord); else return lmCloneStringZ(lm, startFirstWord, endFirstWord - startFirstWord); } char *lmCloneSomeWord(struct lm *lm, char *line, int wordIx) /* Return a clone of the given space-delimited word within line. Returns NULL if