summaryrefslogtreecommitdiff
path: root/src/modules/evas
diff options
context:
space:
mode:
authorPankaj Mittal <m.pankaj@samsung.com>2015-12-10 16:26:56 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-12-10 16:26:56 +0900
commit1363cd757a8dcdc9adeaf47f781ad038446b2014 (patch)
tree5cb4b8deb2c4627b57d170269f0fd2bbb244344c /src/modules/evas
parentd63cc52c584e0b3304699bd1822df18c0b446e2b (diff)
evas_eet: Add Type Safety check
Summary: The Function _evas_canvas3d_eet_file_free(void) is referenced in evas_model_load_file_eet()(file:evas_model_load_eet.c at line 122). This call is under condition if ((eet_file->mesh == NULL) || (eet_file->header == NULL)). when either eet_file->mesh or eet_file->header are NULL, dereference of the corresponding pointer in function "_evas_canvas3d_eet_file_free()" will generate Segmentation Fault. @fix Reviewers: raster, Hermet, tasn, wonsik, spacegrapher, cedric, jpeg Subscribers: singh.amitesh, sachin.dev, alok25, yashu21985, mvsovani, cedric Differential Revision: https://phab.enlightenment.org/D3369
Diffstat (limited to 'src/modules/evas')
-rw-r--r--src/modules/evas/model_loaders/eet/evas_model_load_eet.c13
-rw-r--r--src/modules/evas/model_savers/eet/evas_model_save_eet.c12
2 files changed, 11 insertions, 14 deletions
diff --git a/src/modules/evas/model_loaders/eet/evas_model_load_eet.c b/src/modules/evas/model_loaders/eet/evas_model_load_eet.c
index a36dff4f34..f5b1b6b8ca 100644
--- a/src/modules/evas/model_loaders/eet/evas_model_load_eet.c
+++ b/src/modules/evas/model_loaders/eet/evas_model_load_eet.c
@@ -7,10 +7,6 @@
7#include "evas_common_private.h" 7#include "evas_common_private.h"
8#include "evas_private.h" 8#include "evas_private.h"
9 9
10extern Evas_Canvas3D_File_Eet* eet_file;
11extern const char EVAS_CANVAS3D_FILE_CACHE_FILE_ENTRY[];
12extern Eet_Data_Descriptor *_file_descriptor;
13
14void 10void
15_set_geometry_to_mesh_from_eet_file(Evas_Canvas3D_Mesh *mesh, 11_set_geometry_to_mesh_from_eet_file(Evas_Canvas3D_Mesh *mesh,
16 Evas_Canvas3D_Mesh_Eet *eet_mesh) 12 Evas_Canvas3D_Mesh_Eet *eet_mesh)
@@ -107,8 +103,11 @@ void
107evas_model_load_file_eet(Evas_Canvas3D_Mesh *mesh, Eina_File *file) 103evas_model_load_file_eet(Evas_Canvas3D_Mesh *mesh, Eina_File *file)
108{ 104{
109 Eet_File *ef; 105 Eet_File *ef;
106 Evas_Canvas3D_File_Eet* eet_file;
107 Eet_Data_Descriptor *_file_descriptor;
108
110 109
111 _evas_canvas3d_eet_file_init(); 110 _file_descriptor = _evas_canvas3d_eet_file_get();
112 ef = eet_mmap(file); 111 ef = eet_mmap(file);
113 eet_file = eet_data_read(ef, 112 eet_file = eet_data_read(ef,
114 _file_descriptor, 113 _file_descriptor,
@@ -119,14 +118,14 @@ evas_model_load_file_eet(Evas_Canvas3D_Mesh *mesh, Eina_File *file)
119 if ((eet_file->mesh == NULL) || (eet_file->header == NULL)) 118 if ((eet_file->mesh == NULL) || (eet_file->header == NULL))
120 { 119 {
121 ERR("Reading of file is failed."); 120 ERR("Reading of file is failed.");
122 _evas_canvas3d_eet_file_free(); 121 _evas_canvas3d_eet_file_free(eet_file);
123 return; 122 return;
124 } 123 }
125 124
126 _set_geometry_to_mesh_from_eet_file(mesh, eet_file->mesh); 125 _set_geometry_to_mesh_from_eet_file(mesh, eet_file->mesh);
127 _set_material_to_mesh_from_eet_file(mesh, eet_file->mesh); 126 _set_material_to_mesh_from_eet_file(mesh, eet_file->mesh);
128 127
129 _evas_canvas3d_eet_file_free(); 128 _evas_canvas3d_eet_file_free(eet_file);
130} 129}
131 130
132 131
diff --git a/src/modules/evas/model_savers/eet/evas_model_save_eet.c b/src/modules/evas/model_savers/eet/evas_model_save_eet.c
index ff43a3f851..0ac7e66e44 100644
--- a/src/modules/evas/model_savers/eet/evas_model_save_eet.c
+++ b/src/modules/evas/model_savers/eet/evas_model_save_eet.c
@@ -9,10 +9,6 @@
9#define COMPONENT_OF_DEFAULT_GREY_COLOR 0.3 9#define COMPONENT_OF_DEFAULT_GREY_COLOR 0.3
10#define TRANSPARENCY_OF_DEFAULT_GREY_COLOR 0.5 10#define TRANSPARENCY_OF_DEFAULT_GREY_COLOR 0.5
11 11
12extern Evas_Canvas3D_File_Eet* eet_file;
13extern const char EVAS_CANVAS3D_FILE_CACHE_FILE_ENTRY[];
14extern Eet_Data_Descriptor *_file_descriptor;
15
16void 12void
17_set_geometry_to_eet_file_from_mesh(Evas_Canvas3D_Mesh_Data *mesh, 13_set_geometry_to_eet_file_from_mesh(Evas_Canvas3D_Mesh_Data *mesh,
18 Evas_Canvas3D_Mesh_Eet *eet_mesh, 14 Evas_Canvas3D_Mesh_Eet *eet_mesh,
@@ -154,8 +150,10 @@ evas_model_save_file_eet(const Evas_Canvas3D_Mesh *mesh,
154 Eet_File *ef = eet_open(file, EET_FILE_MODE_WRITE); 150 Eet_File *ef = eet_open(file, EET_FILE_MODE_WRITE);
155 Evas_Canvas3D_Mesh_Eet* eet_mesh = malloc(sizeof(Evas_Canvas3D_Mesh_Eet)); 151 Evas_Canvas3D_Mesh_Eet* eet_mesh = malloc(sizeof(Evas_Canvas3D_Mesh_Eet));
156 Evas_Canvas3D_Header_Eet* eet_header = malloc(sizeof(Evas_Canvas3D_Header_Eet)); 152 Evas_Canvas3D_Header_Eet* eet_header = malloc(sizeof(Evas_Canvas3D_Header_Eet));
153 Eet_Data_Descriptor *_file_descriptor;
154 Evas_Canvas3D_File_Eet *eet_file;
157 155
158 _evas_canvas3d_eet_file_init(); 156 _file_descriptor = _evas_canvas3d_eet_file_get();
159 157
160 eet_file = _evas_canvas3d_eet_file_new(); 158 eet_file = _evas_canvas3d_eet_file_new();
161 159
@@ -176,7 +174,7 @@ evas_model_save_file_eet(const Evas_Canvas3D_Mesh *mesh,
176 ERR("Opening of file is failed."); 174 ERR("Opening of file is failed.");
177 free(eet_mesh); 175 free(eet_mesh);
178 free(eet_header); 176 free(eet_header);
179 _evas_canvas3d_eet_file_free(); 177 _evas_canvas3d_eet_file_free(eet_file);
180 return; 178 return;
181 } 179 }
182 180
@@ -190,6 +188,6 @@ evas_model_save_file_eet(const Evas_Canvas3D_Mesh *mesh,
190 EINA_TRUE); 188 EINA_TRUE);
191 eet_close(ef); 189 eet_close(ef);
192 190
193 _evas_canvas3d_eet_file_free(); 191 _evas_canvas3d_eet_file_free(eet_file);
194} 192}
195 193