>From 449a588d9d0eab225e4bb2467979829f0eb3bae2 Mon Sep 17 00:00:00 2001
From: Michal Jagiello <m.jagiello@samsung.com>
Date: Thu, 20 Sep 2012 09:33:53 +0200
Subject: [PATCH] [LINUXETC-340][LINUXETC-341][LINUXETC-342][LINUXETC-343][LINUXETC-344][LINUXETC-345][LINUXETC-346][LINUXETC-347][LINUXETC-348] Added NULL check and check if the divisor is not equal to zero in ethumb.c file

Change-Id: I2326603255fb3893413d9d6ffb0a547d1e456136
---
 trunk/ethumb/src/lib/ethumb.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/trunk/ethumb/src/lib/ethumb.c b/trunk/ethumb/src/lib/ethumb.c
index ac1637a..bd7fbc0 100644
--- a/trunk/ethumb/src/lib/ethumb.c
+++ b/trunk/ethumb/src/lib/ethumb.c
@@ -1093,6 +1093,8 @@ ethumb_calculate_aspect_from_ratio(Ethumb *e, float ia, int *w, int *h)
 {
    float a;
 
+   EINA_SAFETY_ON_NULL_RETURN(e);
+
    *w = e->tw;
    *h = e->th;
 
@@ -1115,6 +1117,9 @@ ethumb_calculate_aspect(Ethumb *e, int iw, int ih, int *w, int *h)
 {
    float ia;
 
+   if (ih == 0)
+     return;
+
    ia = iw / (float)ih;
 
    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;
 
+   EINA_SAFETY_ON_NULL_RETURN(e);
+
    *fw = e->tw;
    *fh = e->th;
    *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)
 {
    float ia;
+
+   if (ih == 0)
+     return;
+
    ia = iw / (float)ih;
 
    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;
 
+   EINA_SAFETY_ON_NULL_RETURN_VAL(e, 0);
+
    img = e->img;
 
    if (e->frame)
@@ -1236,6 +1249,8 @@ ethumb_image_save(Ethumb *e)
    char *dname;
    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_render(e->sub_e);
 
-- 
1.7.4.1

