sesutil: plug memory leaks
MFC after: 1 week Sponsored by: Axcient Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D33955
This commit is contained in:
parent
4130ea611f
commit
09f29b03dd
@ -484,7 +484,6 @@ objmap(int argc, char **argv __unused)
|
||||
memset(&e_desc, 0, sizeof(e_desc));
|
||||
e_desc.elm_idx = e_ptr[j].elm_idx;
|
||||
e_desc.elm_desc_len = UINT16_MAX;
|
||||
/* XXX memory leak! */
|
||||
e_desc.elm_desc_str = calloc(UINT16_MAX, sizeof(char));
|
||||
if (e_desc.elm_desc_str == NULL) {
|
||||
close(fd);
|
||||
@ -526,6 +525,7 @@ objmap(int argc, char **argv __unused)
|
||||
}
|
||||
print_extra_status(e_ptr[j].elm_type, e_status.cstat, PRINT_STYLE_DASHED);
|
||||
xo_close_instance("elements");
|
||||
free(e_desc.elm_desc_str);
|
||||
free(e_devname.elm_devnames);
|
||||
}
|
||||
xo_close_list("elements");
|
||||
@ -618,7 +618,7 @@ static void
|
||||
show_device(int fd, int elm_idx, encioc_elm_status_t e_status, encioc_elm_desc_t e_desc)
|
||||
{
|
||||
encioc_elm_devnames_t e_devname;
|
||||
char *model, *serial;
|
||||
char *model = NULL, *serial = NULL;
|
||||
off_t size;
|
||||
|
||||
/* Get the device name(s) of the element */
|
||||
@ -635,8 +635,6 @@ show_device(int fd, int elm_idx, encioc_elm_status_t e_status, encioc_elm_desc_t
|
||||
(caddr_t) &e_devname) < 0) {
|
||||
/* We don't care if this fails */
|
||||
e_devname.elm_devnames[0] = '\0';
|
||||
model = NULL;
|
||||
serial = NULL;
|
||||
size = -1;
|
||||
} else {
|
||||
skip_pass_devices(e_devname.elm_devnames, 128);
|
||||
@ -661,6 +659,8 @@ show_device(int fd, int elm_idx, encioc_elm_status_t e_status, encioc_elm_desc_t
|
||||
print_extra_status(ELMTYP_ARRAY_DEV, e_status.cstat, PRINT_STYLE_CSV);
|
||||
xo_emit("\n");
|
||||
xo_close_instance("elements");
|
||||
free(serial);
|
||||
free(model);
|
||||
free(e_devname.elm_devnames);
|
||||
}
|
||||
|
||||
@ -853,6 +853,7 @@ show(int argc, char **argv __unused)
|
||||
*/
|
||||
break;
|
||||
}
|
||||
free(e_desc.elm_desc_str);
|
||||
}
|
||||
if (prev_type != (elm_type_t)-1 &&
|
||||
prev_type != ELMTYP_DEVICE && prev_type != ELMTYP_ARRAY_DEV)
|
||||
|
Loading…
Reference in New Issue
Block a user