close file descriptor in case of errors during read

This commit is contained in:
Damian Kalinowski 2023-05-17 11:03:46 +02:00
parent 4f8520af10
commit 1ea3a3f185

View File

@ -151,6 +151,7 @@ absl::Status GetContents(absl::string_view file_name, std::string* output,
char buf[4096];
size_t ret = fread(buf, 1, 4096, fp);
if (ret == 0 && ferror(fp)) {
fclose(fp);
return mediapipe::InternalErrorBuilder(MEDIAPIPE_LOC)
<< "Error while reading file: " << file_name;
}