]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
DYNBUF.md: note Curl_dyn_add* calls Curl_dyn_free on failure
authorJay Satiro <raysatiro@yahoo.com>
Wed, 1 Mar 2023 03:45:28 +0000 (22:45 -0500)
committerJay Satiro <raysatiro@yahoo.com>
Wed, 1 Mar 2023 09:18:15 +0000 (04:18 -0500)
This is the existing behavior and it has been widely assumed in the
codebase.

Closes https://github.com/curl/curl/pull/10645

docs/DYNBUF.md
lib/dynbuf.c

index 41b022c4227d3bef77e237be2ac6f449b3b32a07..b0d39296ba47f884bbf7afaed025c4bb5eeb12d0 100644 (file)
@@ -37,6 +37,8 @@ CURLcode Curl_dyn_addn(struct dynbuf *s, const void *mem, size_t len);
 
 Append arbitrary data of a given length to the end of the buffer.
 
+If this function fails it calls `Curl_dyn_free` on `dynbuf`.
+
 ## `Curl_dyn_add`
 
 ```c
@@ -45,6 +47,8 @@ CURLcode Curl_dyn_add(struct dynbuf *s, const char *str);
 
 Append a C string to the end of the buffer.
 
+If this function fails it calls `Curl_dyn_free` on `dynbuf`.
+
 ## `Curl_dyn_addf`
 
 ```c
@@ -53,6 +57,8 @@ CURLcode Curl_dyn_addf(struct dynbuf *s, const char *fmt, ...);
 
 Append a `printf()`-style string to the end of the buffer.
 
+If this function fails it calls `Curl_dyn_free` on `dynbuf`.
+
 ## `Curl_dyn_vaddf`
 
 ```c
@@ -61,6 +67,8 @@ CURLcode Curl_dyn_vaddf(struct dynbuf *s, const char *fmt, va_list ap);
 
 Append a `vprintf()`-style string to the end of the buffer.
 
+If this function fails it calls `Curl_dyn_free` on `dynbuf`.
+
 ## `Curl_dyn_reset`
 
 ```c
index 847f6f6ad12abbc5eb8a564a533b76628176020d..bd3b9356c7664d375918fe0ed8c73f92583ff183 100644 (file)
@@ -99,8 +99,7 @@ static CURLcode dyn_nappend(struct dynbuf *s,
        include that as well when it uses this code */
     void *p = realloc(s->bufr, a);
     if(!p) {
-      Curl_safefree(s->bufr);
-      s->leng = s->allc = 0;
+      Curl_dyn_free(s);
       return CURLE_OUT_OF_MEMORY;
     }
     s->bufr = p;