From: Paul Brossier Date: Fri, 10 May 2019 07:53:24 +0000 (+0200) Subject: [effects] remove asserts from aubio_split_str X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=65f78869fafdc01c7248d327d47bbe7804862a53;p=aubio.git [effects] remove asserts from aubio_split_str --- diff --git a/src/effects/rubberband_utils.c b/src/effects/rubberband_utils.c index b48670a7..6e904c41 100644 --- a/src/effects/rubberband_utils.c +++ b/src/effects/rubberband_utils.c @@ -17,7 +17,6 @@ #include #include #include -#include char_t** aubio_split_str(const char_t* str, const char_t sep) { char_t** result = 0; @@ -44,17 +43,18 @@ char_t** aubio_split_str(const char_t* str, const char_t sep) { result = AUBIO_ARRAY(char_t*, count); if (result) { - uint_t idx = 0; + uint_t idx = 0; char_t* params = strtok(input, delim); while (params) { // make sure we don't got in the wild - assert(idx < count); + if (idx >= count) + break; *(result + idx++) = strdup(params); params = strtok(0, delim); } - assert(idx == count - 1); - // add null string at the end - *(result + idx) = 0; + // add null string at the end if needed + if (idx < count - 1) + *(result + idx) = 0; } return result; }