From 74ae887c20924c523e841e5409196333d0b8a19d Mon Sep 17 00:00:00 2001 From: dooglus Date: Sun, 26 Oct 2008 12:15:50 +0000 Subject: [PATCH] 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 --- synfig-core/trunk/src/synfig/loadcanvas.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/synfig-core/trunk/src/synfig/loadcanvas.cpp b/synfig-core/trunk/src/synfig/loadcanvas.cpp index d93dc092..1014435f 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())); -- 2.11.4.GIT