diff options
author | Zolnai Tamás <tamas.zolnai@collabora.com> | 2014-06-13 01:23:42 +0200 |
---|---|---|
committer | Zolnai Tamás <tamas.zolnai@collabora.com> | 2014-06-13 01:23:42 +0200 |
commit | 91b4288a256239af4f53c2f52c3add66b92392e2 (patch) | |
tree | 8c96004a73b2d5634440c935fac39af2d7c76ba9 /external | |
parent | 31f386caa16413c7751855d491b4421441bfd758 (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.
(cherry picked from commit 6904c836b203acbe87a85446a0c59bfbed359240)
Change-Id: I80099195341766f474143014d5949703d47a6fd8
Diffstat (limited to 'external')
-rw-r--r-- | external/libgltf/UnpackedTarball_libgltf.mk | 1 | ||||
-rw-r--r-- | external/libgltf/patches/init_scene_set_handle.patch | 98 |
2 files changed, 99 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..ef34fe34ed3f --- /dev/null +++ b/external/libgltf/patches/init_scene_set_handle.patch @@ -0,0 +1,98 @@ +diff -ur libgltf.org/src/LoadScene.cpp libgltf/src/LoadScene.cpp +--- libgltf.org/src/LoadScene.cpp 2014-06-13 01:13:40.654653289 +0200 ++++ libgltf/src/LoadScene.cpp 2014-06-13 01:15:45.034648018 +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-13 01:13:40.654653289 +0200 ++++ libgltf/src/LoadScene.h 2014-06-13 01:16:03.886647220 +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-13 01:13:40.654653289 +0200 ++++ libgltf/src/RenderScene.cpp 2014-06-13 01:15:11.222649451 +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)
+@@ -844,11 +847,6 @@ +
+ int RenderScene::initRender(glTFHandle* handle)
+ {
+- pScene = new Scene();
+- if(0 == pScene)
+- {
+- return LIBGLTF_MEMORY_ERROR;
+- }
+ int iResult = loadScene(*pScene, handle);
+ if( iResult != LIBGLTF_SUCESS)
+ {
+@@ -1543,4 +1541,4 @@ + int RenderScene::isAnimPlay()
+ {
+ return this->mAnimationPlay ? 1 : 0;
+-} +\ No newline at end of file ++}
|