Fix heap-buffer-overflow
[platform/core/uifw/dali-demo.git] / examples / reflection-demo / gltf-scene.cpp
index 924ead9..9b5a67f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * limitations under the License.
  *
  */
-#include <dali/devel-api/adaptor-framework/file-stream.h>
 
+// HEADER
 #include "gltf-scene.h"
 
-#include "pico-json.h"
+// EXTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/file-stream.h>
 
 namespace
 {
@@ -67,6 +68,7 @@ struct JsonResult
 {
   bool success;
   T    result;
+
   operator T() const
   {
     return static_cast<T>(result);
@@ -161,6 +163,8 @@ void glTF::LoadFromFile(const std::string& filename)
   mBuffer    = LoadFile(binFile);
   jsonBuffer = LoadFile(jsonFile);
 
+  jsonBuffer.push_back('\0'); // It should be null terminated.
+
   // Log errors
   if(mBuffer.empty())
   {