close file descriptor in case of errors during read
This commit is contained in:
parent
4f8520af10
commit
1ea3a3f185
|
@ -151,6 +151,7 @@ absl::Status GetContents(absl::string_view file_name, std::string* output,
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
size_t ret = fread(buf, 1, 4096, fp);
|
size_t ret = fread(buf, 1, 4096, fp);
|
||||||
if (ret == 0 && ferror(fp)) {
|
if (ret == 0 && ferror(fp)) {
|
||||||
|
fclose(fp);
|
||||||
return mediapipe::InternalErrorBuilder(MEDIAPIPE_LOC)
|
return mediapipe::InternalErrorBuilder(MEDIAPIPE_LOC)
|
||||||
<< "Error while reading file: " << file_name;
|
<< "Error while reading file: " << file_name;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user