summaryrefslogtreecommitdiff
path: root/legacy/ethumb
diff options
context:
space:
mode:
authorMichal Jagiello <m.jagiello@samsung.com>2012-10-10 09:31:25 +0000
committerCarsten Haitzler <raster@rasterman.com>2012-10-10 09:31:25 +0000
commit3491137bdb49791ad2e4c88ccd1367db706658dd (patch)
treebcd8b40be37712cbfba08494d911b8f752d0927c /legacy/ethumb
parent0a8bed1b668197c27eb50819bec11e08f822aa8e (diff)
From: Michal Jagiello <m.jagiello@samsung.com>
Subject: [E-devel] [PATCH][ETHUMB] Null checks and checks if divisor is not equal to zero in ethumb.c file In functions ethumb_calculate_aspect_from_ratio, ethumb_calculate_fill_from_ratio, ethumb_plugin_image_resize and ethumb_image_save Ethumb object is not checked if is NULL, what can cause segmentation fault. In functions ethumb_calculate_aspect and ethumb_calculate_fill divisor is not checked if is equal to zero before division. SVN revision: 77736
Diffstat (limited to 'legacy/ethumb')
-rw-r--r--legacy/ethumb/src/lib/ethumb.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/legacy/ethumb/src/lib/ethumb.c b/legacy/ethumb/src/lib/ethumb.c
index ec7f44c828..c76383f804 100644
--- a/legacy/ethumb/src/lib/ethumb.c
+++ b/legacy/ethumb/src/lib/ethumb.c
@@ -1093,6 +1093,8 @@ ethumb_calculate_aspect_from_ratio(Ethumb *e, float ia, int *w, int *h)
1093{ 1093{
1094 float a; 1094 float a;
1095 1095
1096 EINA_SAFETY_ON_NULL_RETURN(e);
1097
1096 *w = e->tw; 1098 *w = e->tw;
1097 *h = e->th; 1099 *h = e->th;
1098 1100
@@ -1115,6 +1117,9 @@ ethumb_calculate_aspect(Ethumb *e, int iw, int ih, int *w, int *h)
1115{ 1117{
1116 float ia; 1118 float ia;
1117 1119
1120 if (ih == 0)
1121 return;
1122
1118 ia = iw / (float)ih; 1123 ia = iw / (float)ih;
1119 1124
1120 ethumb_calculate_aspect_from_ratio(e, ia, w, h); 1125 ethumb_calculate_aspect_from_ratio(e, ia, w, h);
@@ -1125,6 +1130,8 @@ ethumb_calculate_fill_from_ratio(Ethumb *e, float ia, int *fx, int *fy, int *fw,
1125{ 1130{
1126 float a; 1131 float a;
1127 1132
1133 EINA_SAFETY_ON_NULL_RETURN(e);
1134
1128 *fw = e->tw; 1135 *fw = e->tw;
1129 *fh = e->th; 1136 *fh = e->th;
1130 *fx = 0; 1137 *fx = 0;
@@ -1158,6 +1165,10 @@ EAPI void
1158ethumb_calculate_fill(Ethumb *e, int iw, int ih, int *fx, int *fy, int *fw, int *fh) 1165ethumb_calculate_fill(Ethumb *e, int iw, int ih, int *fx, int *fy, int *fw, int *fh)
1159{ 1166{
1160 float ia; 1167 float ia;
1168
1169 if (ih == 0)
1170 return;
1171
1161 ia = iw / (float)ih; 1172 ia = iw / (float)ih;
1162 1173
1163 ethumb_calculate_fill_from_ratio(e, ia, fx, fy, fw, fh); 1174 ethumb_calculate_fill_from_ratio(e, ia, fx, fy, fw, fh);
@@ -1204,6 +1215,8 @@ ethumb_plugin_image_resize(Ethumb *e, int w, int h)
1204{ 1215{
1205 Evas_Object *img; 1216 Evas_Object *img;
1206 1217
1218 EINA_SAFETY_ON_NULL_RETURN_VAL(e, 0);
1219
1207 img = e->img; 1220 img = e->img;
1208 1221
1209 if (e->frame) 1222 if (e->frame)
@@ -1236,6 +1249,8 @@ ethumb_image_save(Ethumb *e)
1236 char *dname; 1249 char *dname;
1237 char flags[256]; 1250 char flags[256];
1238 1251
1252 EINA_SAFETY_ON_NULL_RETURN_VAL(e, 0);
1253
1239 evas_damage_rectangle_add(e->sub_e, 0, 0, e->rw, e->rh); 1254 evas_damage_rectangle_add(e->sub_e, 0, 0, e->rw, e->rh);
1240 evas_render(e->sub_e); 1255 evas_render(e->sub_e);
1241 1256