Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: shwordsplit: final non-whitespace IFS character problem
On Sunday, August 06, 2017 21:01:10 Peter Stephenson wrote:
> @@ -3545,6 +3546,21 @@ spacesplit(char *s, int allownull, int heap, int quote) }
> if (!allownull && t != s)
> *ptr++ = dup("");
> + if (isset(POSIXSTRINGS) && ptr != eptr + 1) {
> + /*
> + * Trailing separators do not generate extra fields in POSIX.
> + * Note this is only the final separator --- if the
> + * immediately preceding field was null it is still counted.
> + * So just back up one.
> + */
> + --ptr;
> + if (!heap) {
> + char **ret2 = realloc(ret, sizeof(*ret) * (ptr+1-ret));
> + ptr -= ret-ret2;
> + free(ret);
> + ret = ret2;
> + }
> + }
> *ptr = NULL;
> return ret;
> }
Is it correct when you free() the pointer that you previously gave to
realloc()? Could not it cause a double free()?
Kamil
Messages sorted by:
Reverse Date,
Date,
Thread,
Author