Skip to content

Commit

Permalink
Fixed crash when loading glTFs with data uri images
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse committed Nov 8, 2023
1 parent d3a2bbf commit 3f5ce9e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

### v0.30.0 - 2023-12-01

##### Fixes :wrench:

- Fixed crash when loading a glTF with data uri images.

### v0.29.0 - 2023-11-01

##### Breaking Changes :mega:
Expand Down
5 changes: 5 additions & 0 deletions CesiumGltfReader/src/GltfReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@ void postprocess(
continue;
}

// Image has already been decoded
if (!image.cesium.pixelData.empty()) {
continue;
}

const BufferView& bufferView =
Model::getSafe(model.bufferViews, image.bufferView);
const Buffer& buffer = Model::getSafe(model.buffers, bufferView.buffer);
Expand Down
7 changes: 5 additions & 2 deletions CesiumGltfReader/src/decodeDataUrls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,13 @@ void decodeDataUrls(

ImageReaderResult imageResult =
reader.readImage(decoded.value().data, options.ktx2TranscodeTargets);
if (imageResult.image) {
image.cesium = std::move(imageResult.image.value());

if (!imageResult.image) {
continue;
}

image.cesium = std::move(imageResult.image.value());

if (options.clearDecodedDataUrls) {
image.uri.reset();
}
Expand Down

0 comments on commit 3f5ce9e

Please sign in to comment.