mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-15 10:17:20 +00:00
sesutil: fix another memory leak
Instead of calloc()ing (and forgetting to free) in a tight loop, just put this small array on the stack. Reported by: Coverity Coverity CID: 1331665 MFC after: 2 weeks Sponsored by: Axcient
This commit is contained in:
parent
a221b104de
commit
9f96f106f8
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=354666
@ -261,19 +261,19 @@ sesled(int argc, char **argv, bool setfault)
|
||||
break;
|
||||
}
|
||||
for (j = 0; j < nobj; j++) {
|
||||
const int devnames_size = 128;
|
||||
char devnames[devnames_size];
|
||||
|
||||
if (all) {
|
||||
do_led(fd, objp[j].elm_idx, objp[j].elm_type,
|
||||
onoff, setfault);
|
||||
continue;
|
||||
}
|
||||
memset(&objdn, 0, sizeof(objdn));
|
||||
memset(devnames, 0, devnames_size);
|
||||
objdn.elm_idx = objp[j].elm_idx;
|
||||
objdn.elm_names_size = 128;
|
||||
objdn.elm_devnames = calloc(128, sizeof(char));
|
||||
if (objdn.elm_devnames == NULL) {
|
||||
close(fd);
|
||||
xo_err(EXIT_FAILURE, "calloc()");
|
||||
}
|
||||
objdn.elm_names_size = devnames_size;
|
||||
objdn.elm_devnames = devnames;
|
||||
if (ioctl(fd, ENCIOC_GETELMDEVNAMES,
|
||||
(caddr_t) &objdn) <0) {
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user