test: log: log_api: Close open fds on error paths
Reported-by: Coverity CID=279091 Signed-off-by: Umang Jain <email@uajain.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
5bb6607933
commit
3706b716eb
1 changed files with 2 additions and 0 deletions
|
@ -87,6 +87,7 @@ protected:
|
||||||
|
|
||||||
if (logSetFile(path) < 0) {
|
if (logSetFile(path) < 0) {
|
||||||
cerr << "Failed to set log file" << endl;
|
cerr << "Failed to set log file" << endl;
|
||||||
|
close(fd);
|
||||||
return TestFail;
|
return TestFail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,6 +98,7 @@ protected:
|
||||||
lseek(fd, 0, SEEK_SET);
|
lseek(fd, 0, SEEK_SET);
|
||||||
if (read(fd, buf, sizeof(buf)) < 0) {
|
if (read(fd, buf, sizeof(buf)) < 0) {
|
||||||
cerr << "Failed to read tmp log file" << endl;
|
cerr << "Failed to read tmp log file" << endl;
|
||||||
|
close(fd);
|
||||||
return TestFail;
|
return TestFail;
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue