Skip to content

Commit

Permalink
Fix crash while creating and loading invalid SpineResources
Browse files Browse the repository at this point in the history
  • Loading branch information
Geequlim committed May 26, 2017
1 parent 8903b6c commit cfd4c55
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions register_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,16 @@ class ResourceFormatLoaderSpine : public ResourceFormatLoader {
json->scale = 1;

res->data = spSkeletonJson_readSkeletonDataFile(json, p_path.utf8().get_data());
spSkeletonJson_dispose(json);
ERR_EXPLAIN(json->error ? json->error : "");
spSkeletonJson_dispose(json);
ERR_FAIL_COND_V(res->data == NULL, RES());
} else {
spSkeletonBinary* bin = spSkeletonBinary_create(res->atlas);
ERR_FAIL_COND_V(bin == NULL, RES());
bin->scale = 1;
res->data = spSkeletonBinary_readSkeletonDataFile(bin, p_path.utf8().get_data());
spSkeletonBinary_dispose(bin);
ERR_EXPLAIN(bin->error ? bin->error : "");
spSkeletonBinary_dispose(bin);
ERR_FAIL_COND_V(res->data == NULL, RES());
}

Expand Down
2 changes: 1 addition & 1 deletion spine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ void Spine::set_resource(Ref<Spine::SpineResource> p_data) {
_spine_dispose();

res = p_data;
if (res.is_null())
if (res.is_null() || !res->data)
return;

skeleton = spSkeleton_create(res->data);
Expand Down

0 comments on commit cfd4c55

Please sign in to comment.