dynbuf: assert for NULL pointer inputs

Help us catch more mistakes.

Closes #12238
This commit is contained in:
Daniel Stenberg 2023-10-31 16:21:35 +01:00
parent 5f78cf503c
commit 27f2352d49
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -77,6 +77,7 @@ static CURLcode dyn_nappend(struct dynbuf *s,
DEBUGASSERT(indx < s->toobig);
DEBUGASSERT(!s->leng || s->bufr);
DEBUGASSERT(a <= s->toobig);
DEBUGASSERT(!len || mem);
if(fit > s->toobig) {
Curl_dyn_free(s);
@ -174,10 +175,12 @@ CURLcode Curl_dyn_addn(struct dynbuf *s, const void *mem, size_t len)
*/
CURLcode Curl_dyn_add(struct dynbuf *s, const char *str)
{
size_t n = strlen(str);
size_t n;
DEBUGASSERT(str);
DEBUGASSERT(s);
DEBUGASSERT(s->init == DYNINIT);
DEBUGASSERT(!s->leng || s->bufr);
n = strlen(str);
return dyn_nappend(s, (unsigned char *)str, n);
}
@ -191,6 +194,7 @@ CURLcode Curl_dyn_vaddf(struct dynbuf *s, const char *fmt, va_list ap)
DEBUGASSERT(s);
DEBUGASSERT(s->init == DYNINIT);
DEBUGASSERT(!s->leng || s->bufr);
DEBUGASSERT(fmt);
rc = Curl_dyn_vprintf(s, fmt, ap);
if(!rc)