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;
|
break;
|
||||||
}
|
}
|
||||||
for (j = 0; j < nobj; j++) {
|
for (j = 0; j < nobj; j++) {
|
||||||
|
const int devnames_size = 128;
|
||||||
|
char devnames[devnames_size];
|
||||||
|
|
||||||
if (all) {
|
if (all) {
|
||||||
do_led(fd, objp[j].elm_idx, objp[j].elm_type,
|
do_led(fd, objp[j].elm_idx, objp[j].elm_type,
|
||||||
onoff, setfault);
|
onoff, setfault);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
memset(&objdn, 0, sizeof(objdn));
|
memset(&objdn, 0, sizeof(objdn));
|
||||||
|
memset(devnames, 0, devnames_size);
|
||||||
objdn.elm_idx = objp[j].elm_idx;
|
objdn.elm_idx = objp[j].elm_idx;
|
||||||
objdn.elm_names_size = 128;
|
objdn.elm_names_size = devnames_size;
|
||||||
objdn.elm_devnames = calloc(128, sizeof(char));
|
objdn.elm_devnames = devnames;
|
||||||
if (objdn.elm_devnames == NULL) {
|
|
||||||
close(fd);
|
|
||||||
xo_err(EXIT_FAILURE, "calloc()");
|
|
||||||
}
|
|
||||||
if (ioctl(fd, ENCIOC_GETELMDEVNAMES,
|
if (ioctl(fd, ENCIOC_GETELMDEVNAMES,
|
||||||
(caddr_t) &objdn) <0) {
|
(caddr_t) &objdn) <0) {
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user