mirror of
https://github.com/curl/curl.git
synced 2026-08-26 10:53:36 +03:00
dynbuf: return NULL when there's no buffer length
... as returning a "" is not a good idea as the string is supposed to be
allocated and returning a const string will cause issues.
Reported-by: Brian Carpenter
Follow-up to ed35d6590e
Closes #5405
This commit is contained in:
parent
2c598cc778
commit
3df42ca949
2 changed files with 8 additions and 8 deletions
|
|
@ -60,17 +60,17 @@ larger than the buffer length.
|
||||||
|
|
||||||
char *Curl_dyn_ptr(const struct dynbuf *s);
|
char *Curl_dyn_ptr(const struct dynbuf *s);
|
||||||
|
|
||||||
Returns a `char *` to the buffer. Since the buffer may be reallocated, this
|
Returns a `char *` to the buffer if it has a length, otherwise a NULL. Since
|
||||||
pointer should not be trusted or used anymore after the next buffer
|
the buffer may be reallocated, this pointer should not be trusted or used
|
||||||
manipulation call.
|
anymore after the next buffer manipulation call.
|
||||||
|
|
||||||
## uptr
|
## uptr
|
||||||
|
|
||||||
unsigned char *Curl_dyn_uptr(const struct dynbuf *s);
|
unsigned char *Curl_dyn_uptr(const struct dynbuf *s);
|
||||||
|
|
||||||
Returns an `unsigned char *` to the buffer. Since the buffer may be
|
Returns an `unsigned char *` to the buffer if it has a length, otherwise a
|
||||||
reallocated, this pointer should not be trusted or used anymore after the next
|
NULL. Since the buffer may be reallocated, this pointer should not be trusted
|
||||||
buffer manipulation call.
|
or used anymore after the next buffer manipulation call.
|
||||||
|
|
||||||
## len
|
## len
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -201,7 +201,7 @@ char *Curl_dyn_ptr(const struct dynbuf *s)
|
||||||
DEBUGASSERT(s);
|
DEBUGASSERT(s);
|
||||||
DEBUGASSERT(s->init == DYNINIT);
|
DEBUGASSERT(s->init == DYNINIT);
|
||||||
DEBUGASSERT(!s->leng || s->bufr);
|
DEBUGASSERT(!s->leng || s->bufr);
|
||||||
return s->leng ? s->bufr : (char *)"";
|
return s->bufr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -212,7 +212,7 @@ unsigned char *Curl_dyn_uptr(const struct dynbuf *s)
|
||||||
DEBUGASSERT(s);
|
DEBUGASSERT(s);
|
||||||
DEBUGASSERT(s->init == DYNINIT);
|
DEBUGASSERT(s->init == DYNINIT);
|
||||||
DEBUGASSERT(!s->leng || s->bufr);
|
DEBUGASSERT(!s->leng || s->bufr);
|
||||||
return s->leng ? (unsigned char *)s->bufr : (unsigned char *)"";
|
return (unsigned char *)s->bufr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue