summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2014-02-14 11:23:04 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2014-02-14 11:25:25 +0900
commiteb1c452156641cdc14a5ba50b8cf661641baf736 (patch)
treed2e8cbc89ad5f95a22aaf700e87ef723ba6c0113
parent568c014dc9bcade3c664faccfb601516a9174ed2 (diff)
Evas filters: Prevent division by zero
These can not happen, as all weights > 0. Add a CRI message in case of div0. Fixes CID 1174081, CID 1174080.
-rw-r--r--src/lib/evas/filters/evas_filter_blur.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/lib/evas/filters/evas_filter_blur.c b/src/lib/evas/filters/evas_filter_blur.c
index b6ae30455b..07b095ae28 100644
--- a/src/lib/evas/filters/evas_filter_blur.c
+++ b/src/lib/evas/filters/evas_filter_blur.c
@@ -452,6 +452,7 @@ _gaussian_blur_step_alpha(DATA8 *src, DATA8 *dst, int radius, int len, int step,
452 acc += (*s) * weights[j + radius - k]; 452 acc += (*s) * weights[j + radius - k];
453 divider += weights[j + radius - k]; 453 divider += weights[j + radius - k];
454 } 454 }
455 if (!divider) goto div_zero;
455 *dst = acc / divider; 456 *dst = acc / divider;
456 } 457 }
457 458
@@ -476,8 +477,14 @@ _gaussian_blur_step_alpha(DATA8 *src, DATA8 *dst, int radius, int len, int step,
476 acc += (*s) * weights[j]; 477 acc += (*s) * weights[j];
477 divider += weights[j]; 478 divider += weights[j];
478 } 479 }
480 if (!divider) goto div_zero;
479 *dst = acc / divider; 481 *dst = acc / divider;
480 } 482 }
483
484 return;
485
486div_zero:
487 CRI("Division by zero avoided! Something is very wrong here!");
481} 488}
482 489
483static void 490static void
@@ -504,6 +511,7 @@ _gaussian_blur_step_rgba(DATA32 *src, DATA32 *dst, int radius, int len, int step
504 acc[BLUE] += B_VAL(s) * weights[weightidx]; 511 acc[BLUE] += B_VAL(s) * weights[weightidx];
505 divider += weights[weightidx]; 512 divider += weights[weightidx];
506 } 513 }
514 if (!divider) goto div_zero;
507 A_VAL(dst) = acc[ALPHA] / divider; 515 A_VAL(dst) = acc[ALPHA] / divider;
508 R_VAL(dst) = acc[RED] / divider; 516 R_VAL(dst) = acc[RED] / divider;
509 G_VAL(dst) = acc[GREEN] / divider; 517 G_VAL(dst) = acc[GREEN] / divider;
@@ -542,11 +550,17 @@ _gaussian_blur_step_rgba(DATA32 *src, DATA32 *dst, int radius, int len, int step
542 acc[BLUE] += B_VAL(s) * weights[j]; 550 acc[BLUE] += B_VAL(s) * weights[j];
543 divider += weights[j]; 551 divider += weights[j];
544 } 552 }
553 if (!divider) goto div_zero;
545 A_VAL(dst) = acc[ALPHA] / divider; 554 A_VAL(dst) = acc[ALPHA] / divider;
546 R_VAL(dst) = acc[RED] / divider; 555 R_VAL(dst) = acc[RED] / divider;
547 G_VAL(dst) = acc[GREEN] / divider; 556 G_VAL(dst) = acc[GREEN] / divider;
548 B_VAL(dst) = acc[BLUE] / divider; 557 B_VAL(dst) = acc[BLUE] / divider;
549 } 558 }
559
560 return;
561
562div_zero:
563 CRI("Division by zero avoided! Something is very wrong here!");
550} 564}
551 565
552static void 566static void