mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-11-29 01:03:57 +03:00
buffer: Do not call memcpy with null arguments
This allows compiling and testing with undefined sanitizer. Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
committed by
Andreas Schneider
parent
87b8d232bd
commit
eb796b4bbb
@@ -145,9 +145,11 @@ static int realloc_buffer(struct ssh_buffer_struct *buffer, size_t needed) {
|
|||||||
if (new == NULL) {
|
if (new == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if (buffer->used > 0) {
|
||||||
memcpy(new, buffer->data,buffer->used);
|
memcpy(new, buffer->data,buffer->used);
|
||||||
explicit_bzero(buffer->data, buffer->used);
|
explicit_bzero(buffer->data, buffer->used);
|
||||||
SAFE_FREE(buffer->data);
|
SAFE_FREE(buffer->data);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
new = realloc(buffer->data, needed);
|
new = realloc(buffer->data, needed);
|
||||||
if (new == NULL) {
|
if (new == NULL) {
|
||||||
|
|||||||
Reference in New Issue
Block a user