mirror of
https://github.com/opnsense/src.git
synced 2026-06-09 08:43:19 -04:00
Fix CID 1215129: move the call to lseek(2) before the call to malloc(3)
so that the error path (taken due to lseek(2) failing) isn't leaking memory.
This commit is contained in:
parent
8e14e4a03a
commit
bce9a24a0e
1 changed files with 2 additions and 2 deletions
|
|
@ -98,11 +98,11 @@ image_copyout(int fd)
|
|||
|
||||
ofs = lseek(fd, 0L, SEEK_CUR);
|
||||
|
||||
if (lseek(image_fd, 0, SEEK_SET) != 0)
|
||||
return (errno);
|
||||
buffer = malloc(BUFFER_SIZE);
|
||||
if (buffer == NULL)
|
||||
return (errno);
|
||||
if (lseek(image_fd, 0, SEEK_SET) != 0)
|
||||
return (errno);
|
||||
error = 0;
|
||||
while (1) {
|
||||
rdsz = read(image_fd, buffer, BUFFER_SIZE);
|
||||
|
|
|
|||
Loading…
Reference in a new issue