diff --git a/src/stb-image-source.cc b/src/stb-image-source.cc index 764b997..88e2ca5 100644 --- a/src/stb-image-source.cc +++ b/src/stb-image-source.cc @@ -111,7 +111,10 @@ bool STBImageSource::LoadAndScale(const DisplayOptions &options, int w, h; uint8_t *data = stbi__load_and_postprocess_8bit( &context, &w, &h, &channels, kDesiredChannels); - if (!data) return false; + if (!data) { + fclose(img_file); + return false; + } orig_width_ = w; orig_height_ = h; @@ -130,6 +133,8 @@ bool STBImageSource::LoadAndScale(const DisplayOptions &options, ? (int)frames_.size() : std::min(frame_count, (int)frames_.size()); + fclose(img_file); + return !frames_.empty(); }