mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-04 12:20:42 +09:00
sftp: Add NULL check in sftp_ext_free()
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
committed by
Andreas Schneider
parent
61ad276a87
commit
8ddbe7bec6
21
src/sftp.c
21
src/sftp.c
@@ -81,19 +81,26 @@ static sftp_ext sftp_ext_new(void) {
|
||||
|
||||
static void sftp_ext_free(sftp_ext ext)
|
||||
{
|
||||
unsigned int i;
|
||||
size_t i;
|
||||
|
||||
if (ext == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ext->count) {
|
||||
for (i = 0; i < ext->count; i++) {
|
||||
SAFE_FREE(ext->name[i]);
|
||||
SAFE_FREE(ext->data[i]);
|
||||
if (ext->count > 0) {
|
||||
if (ext->name != NULL) {
|
||||
for (i = 0; i < ext->count; i++) {
|
||||
SAFE_FREE(ext->name[i]);
|
||||
}
|
||||
SAFE_FREE(ext->name);
|
||||
}
|
||||
|
||||
if (ext->data != NULL) {
|
||||
for (i = 0; i < ext->count; i++) {
|
||||
SAFE_FREE(ext->data[i]);
|
||||
}
|
||||
SAFE_FREE(ext->data);
|
||||
}
|
||||
SAFE_FREE(ext->name);
|
||||
SAFE_FREE(ext->data);
|
||||
}
|
||||
|
||||
SAFE_FREE(ext);
|
||||
|
||||
Reference in New Issue
Block a user