Skip to content

Commit

Permalink
fix: always seek to the beginning of the ioproxy during open for DDS …
Browse files Browse the repository at this point in the history
…and PSD files (#4048)

During certain creation tasks, open may be called twice on the
ImageInput. If the first open call moves the ioproxy forward, then the
second call to open may fail.

DDS and PSD were affected so they've been fixed to mirror what other
formats (png, hdr, tga, etc.) do by always explicitly seeking to
position 0.

Fixes #4043 

Signed-off-by: Jesse Yurkovich <[email protected]>
  • Loading branch information
jessey-git authored Nov 3, 2023
1 parent 8450736 commit f4e7ac1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/dds.imageio/ddsinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ DDSInput::open(const std::string& name, ImageSpec& newspec)

if (!ioproxy_use_or_open(name))
return false;
ioseek(0);

static_assert(sizeof(dds_header) == 128, "dds header size does not match");
if (!ioread(&m_dds, sizeof(m_dds), 1))
Expand Down
1 change: 1 addition & 0 deletions src/psd.imageio/psdinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ PSDInput::open(const std::string& name, ImageSpec& newspec)
m_filename = name;
if (!ioproxy_use_or_open(name))
return false;
ioseek(0);

// File Header
if (!load_header()) {
Expand Down

0 comments on commit f4e7ac1

Please sign in to comment.