Fix 2195749: "Crash when try to open a sif with canvas size to be 0,0". Check the...
authordooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Sun, 26 Oct 2008 12:15:50 +0000 (12:15 +0000)
committerdooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Sun, 26 Oct 2008 12:15:50 +0000 (12:15 +0000)
git-svn-id: https://synfig.svn.sourceforge.net/svnroot/synfig@2130 1f10aa63-cdf2-0310-b900-c93c546f37ac

synfig-core/trunk/src/synfig/loadcanvas.cpp

index d93dc09..1014435 100644 (file)
@@ -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()));