diff options
author | Zolnai Tamás <tamas.zolnai@collabora.com> | 2014-06-13 00:23:37 +0200 |
---|---|---|
committer | Zolnai Tamás <tamas.zolnai@collabora.com> | 2014-06-13 00:23:37 +0200 |
commit | 6904c836b203acbe87a85446a0c59bfbed359240 (patch) | |
tree | 61f5557f5bafff9b46c78b2152a953a3991d8565 /external/libgltf | |
parent | 573ced4087f46788a8596fb89c657d3427be4bf8 (diff) |
glTF: Avoid segmentation fault when one of the input files can't be loaded
libgltf: Parser releases the glTFHandle, but it was not connected to
the corresponding handle by RenderScene::initScene. So when rendering
stopped during file loading because of missing file, Parser's handle
member was an uninitialized pointer so it crashed by calling release
method.
Change-Id: I80099195341766f474143014d5949703d47a6fd8
Diffstat (limited to 'external/libgltf')
-rw-r--r-- | external/libgltf/UnpackedTarball_libgltf.mk | 1 | ||||
-rw-r--r-- | external/libgltf/patches/init_scene_set_handle.patch | 86 |
2 files changed, 87 insertions, 0 deletions
diff --git a/external/libgltf/UnpackedTarball_libgltf.mk b/external/libgltf/UnpackedTarball_libgltf.mk index 32377075c2a1..a1314bb19484 100644 --- a/external/libgltf/UnpackedTarball_libgltf.mk +++ b/external/libgltf/UnpackedTarball_libgltf.mk @@ -21,6 +21,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,libgltf,\ external/libgltf/patches/openmp-disable.patch \ external/libgltf/patches/rgba_textures.patch \ external/libgltf/patches/deallocation_fix.patch \ + external/libgltf/patches/init_scene_set_handle.patch \ )) # vim: set noet sw=4 ts=4: diff --git a/external/libgltf/patches/init_scene_set_handle.patch b/external/libgltf/patches/init_scene_set_handle.patch new file mode 100644 index 000000000000..b0dba8e41150 --- /dev/null +++ b/external/libgltf/patches/init_scene_set_handle.patch @@ -0,0 +1,86 @@ +diff -ur libgltf.org/src/LoadScene.cpp libgltf/src/LoadScene.cpp +--- libgltf.org/src/LoadScene.cpp 2014-06-12 12:11:58.945707220 +0200 ++++ libgltf/src/LoadScene.cpp 2014-06-12 12:13:14.129704086 +0200 +@@ -148,10 +148,14 @@ + return true;
+ }
+
+-int Parser::parseScene(Scene* pscene)
++void Parser::setScene(Scene* pscene)
++{
++ pScene = pscene;
++}
++
++int Parser::parseScene()
+ {
+ int status;
+- this->pScene = pscene;
+
+ {
+ TRACE_TIME ("parseScene->readBuffers", CPU);
+diff -ur libgltf.org/src/LoadScene.h libgltf/src/LoadScene.h +--- libgltf.org/src/LoadScene.h 2014-06-12 12:11:58.945707220 +0200 ++++ libgltf/src/LoadScene.h 2014-06-12 12:12:11.805706684 +0200 +@@ -27,7 +27,8 @@ + public:
+ glTFHandle* getFileNameInJson(const std::string& jsonFile);
+ bool releaseFileName();
+- int parseScene(Scene* pscene);
++ void setScene(Scene* pscene);
++ int parseScene();
+ bool parseJsonFile();
+ void setJsonInfo(const std::string& sbuffer);
+ void setJsonInfo(const std::string& direct, const std::string& fileName);
+@@ -81,4 +82,4 @@ + bool is_json_in_buffer;
+ };
+
+-#endif +\ No newline at end of file ++#endif
+diff -ur libgltf.org/src/RenderScene.cpp libgltf/src/RenderScene.cpp +--- libgltf.org/src/RenderScene.cpp 2014-06-12 12:11:58.949707220 +0200 ++++ libgltf/src/RenderScene.cpp 2014-06-12 12:12:13.509706613 +0200 +@@ -561,7 +561,7 @@ + {
+ return LIBGLTF_PARSE_JSON_ERROR;
+ }
+- int iStatus = mLoadJson.parseScene(&scene);
++ int iStatus = mLoadJson.parseScene();
+ if (iStatus != LIBGLTF_SUCESS)
+ {
+ return iStatus;
+@@ -571,12 +571,11 @@ +
+ int RenderScene::loadScene(Scene& scene, glTFHandle* handle)
+ {
+- scene.setGltfHandle(handle);
+ try
+ {
+ {
+ TRACE_TIME ("loadScene->parseScene", CPU);
+- int iStatus = mLoadJson.parseScene(&scene);
++ int iStatus = mLoadJson.parseScene();
+ if (iStatus != LIBGLTF_SUCESS)
+ {
+ return iStatus;
+@@ -612,7 +611,11 @@ + }
+ }
+ string tmpFileName(jsonfile->filename);
+- return mLoadJson.getFileNameInJson(tmpFileName);
++ glTFHandle* handle = mLoadJson.getFileNameInJson(tmpFileName);
++ pScene = new Scene();
++ pScene->setGltfHandle(handle);
++ mLoadJson.setScene(pScene);
++ return handle;
+ }
+
+ unsigned int RenderScene::bindAttribute(const Attribute* pAttr)
+@@ -1543,4 +1546,4 @@ + int RenderScene::isAnimPlay()
+ {
+ return this->mAnimationPlay ? 1 : 0;
+-} +\ No newline at end of file ++}
|