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
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=266509
@ -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 New Issue
Block a user