mirror of
https://git.proxmox.com/git/mirror_corosync
synced 2025-07-23 21:02:52 +00:00
Fix free of ring status information when memory allocation fails during
allocation of the ring status information. git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2852 fd59a12c-fef9-0310-b244-a6a79926bd2f
This commit is contained in:
parent
6d79a218e2
commit
02cddf6854
28
lib/cfg.c
28
lib/cfg.c
@ -272,7 +272,7 @@ corosync_cfg_ring_status_get (
|
||||
struct cfg_instance *cfg_instance;
|
||||
struct req_lib_cfg_ringstatusget req_lib_cfg_ringstatusget;
|
||||
struct res_lib_cfg_ringstatusget res_lib_cfg_ringstatusget;
|
||||
unsigned int i;
|
||||
unsigned int i, j;
|
||||
cs_error_t error;
|
||||
struct iovec iov;
|
||||
|
||||
@ -303,7 +303,7 @@ corosync_cfg_ring_status_get (
|
||||
*status = malloc (sizeof (char *) * *interface_count);
|
||||
if (*status == NULL) {
|
||||
error = CS_ERR_NO_MEMORY;
|
||||
goto error_free_interface_names;
|
||||
goto error_free_interface_names_array;
|
||||
}
|
||||
memset (*status, 0, sizeof (char *) * *interface_count);
|
||||
|
||||
@ -311,25 +311,33 @@ corosync_cfg_ring_status_get (
|
||||
(*(interface_names))[i] = strdup (res_lib_cfg_ringstatusget.interface_name[i]);
|
||||
if ((*(interface_names))[i] == NULL) {
|
||||
error = CS_ERR_NO_MEMORY;
|
||||
goto error_free_contents;
|
||||
goto error_free_interface_names;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < res_lib_cfg_ringstatusget.interface_count; i++) {
|
||||
(*(status))[i] = strdup (res_lib_cfg_ringstatusget.interface_status[i]);
|
||||
if ((*(status))[i] == NULL) {
|
||||
error = CS_ERR_NO_MEMORY;
|
||||
goto error_free_contents;
|
||||
goto error_free_status;
|
||||
}
|
||||
}
|
||||
goto no_error;
|
||||
|
||||
error_free_contents:
|
||||
for (i = 0; i < res_lib_cfg_ringstatusget.interface_count; i++) {
|
||||
free (*interface_names + i);
|
||||
free (*status + i);
|
||||
error_free_status:
|
||||
for (j = 0; j < i; j++) {
|
||||
free ((*(status))[j]);
|
||||
}
|
||||
|
||||
free (*status);
|
||||
i = *interface_count;
|
||||
|
||||
error_free_interface_names:
|
||||
for (j = 0; j < i; j++) {
|
||||
free ((*(interface_names))[j]);
|
||||
}
|
||||
|
||||
free (*status);
|
||||
|
||||
error_free_interface_names_array:
|
||||
free (*interface_names);
|
||||
|
||||
no_error:
|
||||
|
Loading…
Reference in New Issue
Block a user