From: dooglus Date: Sun, 26 Oct 2008 12:15:50 +0000 (+0000) Subject: Fix 2195749: "Crash when try to open a sif with canvas size to be 0,0". Check the... X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=74ae887c20924c523e841e5409196333d0b8a19d;p=synfig.git Fix 2195749: "Crash when try to open a sif with canvas size to be 0,0". Check the width and height when loading a canvas. Prohibit and size less than one. git-svn-id: https://synfig.svn.sourceforge.net/svnroot/synfig@2130 1f10aa63-cdf2-0310-b900-c93c546f37ac --- diff --git a/synfig-core/trunk/src/synfig/loadcanvas.cpp b/synfig-core/trunk/src/synfig/loadcanvas.cpp index d93dc09..1014435 100644 --- a/synfig-core/trunk/src/synfig/loadcanvas.cpp +++ b/synfig-core/trunk/src/synfig/loadcanvas.cpp @@ -1884,10 +1884,20 @@ CanvasParser::parse_canvas(xmlpp::Element *element,Canvas::Handle parent,bool in canvas->set_version(parent->get_version()); if(element->get_attribute("width")) - canvas->rend_desc().set_w(atoi(element->get_attribute("width")->get_value().c_str())); + { + int width = atoi(element->get_attribute("width")->get_value().c_str()); + if (width < -1) + fatal_error(element, _("Canvas with width or height less than one is not allowed")); + canvas->rend_desc().set_w(width); + } if(element->get_attribute("height")) - canvas->rend_desc().set_h(atoi(element->get_attribute("height")->get_value().c_str())); + { + int height = atoi(element->get_attribute("height")->get_value().c_str()); + if (height < -1) + fatal_error(element, _("Canvas with width or height less than one is not allowed")); + canvas->rend_desc().set_h(height); + } if(element->get_attribute("xres")) canvas->rend_desc().set_x_res(atof(element->get_attribute("xres")->get_value().c_str()));