summaryrefslogtreecommitdiffstats
path: root/libssh/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'libssh/buffer.c')
-rw-r--r--libssh/buffer.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libssh/buffer.c b/libssh/buffer.c
index 7e4a80f..32a1f5b 100644
--- a/libssh/buffer.c
+++ b/libssh/buffer.c
@@ -68,16 +68,19 @@ void buffer_free(struct buffer_struct *buffer) {
static int realloc_buffer(struct buffer_struct *buffer, int needed) {
int smallest = 1;
+ char *new = NULL;
/* Find the smallest power of two which is greater or equal to needed */
while(smallest <= needed) {
smallest <<= 1;
}
needed = smallest;
- buffer->data = realloc(buffer->data, needed);
- if (buffer->data == NULL) {
+ new = realloc(buffer->data, needed);
+ if (new == NULL) {
return -1;
}
+ buffer->data = new;
buffer->allocated = needed;
+
return 0;
}