ap

An audio player suited to my tastes
Log | Files | Refs | README | LICENSE

commit b7194efb05c0c01eb926d72ce10471f3a4f5d32d
parent bbc6de2ef2db399c00e09872070261bd2e5057c2
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date:   Mon, 15 May 2023 12:23:57 -0700

Detect when apunquote fails in split()

When apunquote returns NULL, you must check the value of *sp to
determine whether it was due to an error or the end of the string.
It seems split assumed NULL meant there was no more arguments to
be gotten and didn't check the value of *sp which could cause some
arguments to be "ignored".

Diffstat:
Maps/split.c | 8++++++++
1 file changed, 8 insertions(+), 0 deletions(-)

diff --git a/aps/split.c b/aps/split.c @@ -22,6 +22,8 @@ #include <stdlib.h> #include <string.h> +#include "arg.h" + int countsplits(char *s, int (*sep)(int)) { @@ -51,5 +53,11 @@ split(char *s, int (*sep)(int)) ap = args; while ((*ap = apunquote(&s, sep))) ++ap; + + if (s) { + argfree(args); + return NULL; + } + return args; }