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
This commit is contained in:
Michal Jagiello 2012-10-10 09:31:25 +00:00 committed by Carsten Haitzler
parent 0a8bed1b66
commit 3491137bdb
1 changed files with 15 additions and 0 deletions

View File

@ -1093,6 +1093,8 @@ ethumb_calculate_aspect_from_ratio(Ethumb *e, float ia, int *w, int *h)
{ {
float a; float a;
EINA_SAFETY_ON_NULL_RETURN(e);
*w = e->tw; *w = e->tw;
*h = e->th; *h = e->th;
@ -1115,6 +1117,9 @@ ethumb_calculate_aspect(Ethumb *e, int iw, int ih, int *w, int *h)
{ {
float ia; float ia;
if (ih == 0)
return;
ia = iw / (float)ih; ia = iw / (float)ih;
ethumb_calculate_aspect_from_ratio(e, ia, w, h); 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,
{ {
float a; float a;
EINA_SAFETY_ON_NULL_RETURN(e);
*fw = e->tw; *fw = e->tw;
*fh = e->th; *fh = e->th;
*fx = 0; *fx = 0;
@ -1158,6 +1165,10 @@ EAPI void
ethumb_calculate_fill(Ethumb *e, int iw, int ih, int *fx, int *fy, int *fw, int *fh) ethumb_calculate_fill(Ethumb *e, int iw, int ih, int *fx, int *fy, int *fw, int *fh)
{ {
float ia; float ia;
if (ih == 0)
return;
ia = iw / (float)ih; ia = iw / (float)ih;
ethumb_calculate_fill_from_ratio(e, ia, fx, fy, fw, fh); 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)
{ {
Evas_Object *img; Evas_Object *img;
EINA_SAFETY_ON_NULL_RETURN_VAL(e, 0);
img = e->img; img = e->img;
if (e->frame) if (e->frame)
@ -1236,6 +1249,8 @@ ethumb_image_save(Ethumb *e)
char *dname; char *dname;
char flags[256]; char flags[256];
EINA_SAFETY_ON_NULL_RETURN_VAL(e, 0);
evas_damage_rectangle_add(e->sub_e, 0, 0, e->rw, e->rh); evas_damage_rectangle_add(e->sub_e, 0, 0, e->rw, e->rh);
evas_render(e->sub_e); evas_render(e->sub_e);