From 7764d30ea3353f1ea7634a9407112185e56c60a2 Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Mon, 23 May 2016 14:17:25 +0200 Subject: [PATCH] avoid division by zero and fix segfault Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/9f20b278903c7d3af4b8de253c22a7b55b878273 Author: Jacek Jendrzej Date: 2016-05-23 (Mon, 23 May 2016) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/components/cc_draw.cpp | 2 +- src/gui/components/cc_item_picture.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/components/cc_draw.cpp b/src/gui/components/cc_draw.cpp index 0dd74c5be..b5ef5bf0d 100644 --- a/src/gui/components/cc_draw.cpp +++ b/src/gui/components/cc_draw.cpp @@ -431,7 +431,7 @@ bool CCDraw::CheckFbData(const cc_fbdata_t& fbdata, const char* func, const int //screen area save fb_pixel_t* CCDraw::getScreen(int ax, int ay, int dx, int dy) { - if (dx * dy == 0) + if (dx < 1 || dy < 1 || dx * dy == 0) return NULL; dprintf(DEBUG_INFO, "[CCDraw] INFO! [%s - %d], ax = %d, ay = %d, dx = %d, dy = %d\n", __func__, __LINE__, ax, ay, dx, dy); diff --git a/src/gui/components/cc_item_picture.cpp b/src/gui/components/cc_item_picture.cpp index 91f59a9b5..be77e7a44 100644 --- a/src/gui/components/cc_item_picture.cpp +++ b/src/gui/components/cc_item_picture.cpp @@ -216,7 +216,7 @@ void CComponentsPicture::initCCItem() * by setters setWidth/setHeight * these steps are required to assign the current image dimensions to item dimensions */ - if (keep_dx_aspect){ + if (keep_dx_aspect && dy){ float h_ratio = float(height)*100/(float)dy; width = int(h_ratio*(float)dx/100); #ifdef BOXMODEL_APOLLO @@ -224,7 +224,7 @@ void CComponentsPicture::initCCItem() width = GetWidth4FB_HW_ACC(x+fr_thickness, width-2*fr_thickness)+2*fr_thickness; #endif } - if (keep_dy_aspect){ + if (keep_dy_aspect & dx){ float w_ratio = float(width)*100/(float)dx; height = int(w_ratio*(float)dy/100); }