diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2026-10-25 02:49:47 +0200 |
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2026-10-25 02:49:47 +0200 |
| commit | e6c55cf1f8b15d48d87174846669a1a1464668cb (patch) | |
| tree | d55137049d150ff13bff142fe70b70f9372eb999 | |
| parent | 4afeaeb4b6ab6c56e582436b17f367e216f16de1 (diff) | |
Don't let the new iovec allocation dangle in case of a malloc failure for its new data
| -rw-r--r-- | ot_iovec.c | 3 |
1 files changed, 2 insertions, 1 deletions
| @@ -20,6 +20,8 @@ void *iovec_increase(size_t *iovec_entries, struct iovec **iovector, size_t new_ | |||
| 20 | if (!new_vec) | 20 | if (!new_vec) |
| 21 | return NULL; | 21 | return NULL; |
| 22 | 22 | ||
| 23 | *iovector = new_vec; | ||
| 24 | |||
| 23 | /* Only allocate after we have a place to store the pointer */ | 25 | /* Only allocate after we have a place to store the pointer */ |
| 24 | new_data = malloc(new_alloc); | 26 | new_data = malloc(new_alloc); |
| 25 | if (!new_data) | 27 | if (!new_data) |
| @@ -28,7 +30,6 @@ void *iovec_increase(size_t *iovec_entries, struct iovec **iovector, size_t new_ | |||
| 28 | new_vec[new_entries - 1].iov_base = new_data; | 30 | new_vec[new_entries - 1].iov_base = new_data; |
| 29 | new_vec[new_entries - 1].iov_len = new_alloc; | 31 | new_vec[new_entries - 1].iov_len = new_alloc; |
| 30 | 32 | ||
| 31 | *iovector = new_vec; | ||
| 32 | ++*iovec_entries; | 33 | ++*iovec_entries; |
| 33 | return new_data; | 34 | return new_data; |
| 34 | } | 35 | } |
