Source/Gorgon/Geometry/Size.h

branch
4.x-dev
changeset 1461
6bbecfcb304e
parent 1459
f1d6091311ff
child 1687
dc9150a2185d
--- a/Source/Gorgon/Geometry/Size.h	Wed Oct 07 16:46:11 2020 +0300
+++ b/Source/Gorgon/Geometry/Size.h	Wed Oct 07 20:33:51 2020 +0300
@@ -48,8 +48,14 @@
 		/// Conversion from string
 		explicit basic_Size(const std::string &str) {
 			auto s=str.begin();
+
+			if(s == str.end())
+				Width = Height = 0;
 			
-			while(*s==' ' || *s=='\t') s++;
+			while(s != str.end() && (*s==' ' || *s=='\t')) s++;
+
+			if(s == str.end())
+				Width = Height = 0;
             
             auto pos = str.find_first_of('x', s-str.begin());
             if(pos != str.npos)
@@ -59,9 +65,11 @@
             
 			while(s!=str.end() && *s!='x' && *s!=',') s++;
 			
-			if(*s=='x' || *s==',') s++;
-			
-			Height=String::To<T_>(&str[s-str.begin()]);
+			if(s != str.end()) {
+				if(*s=='x' || *s==',') s++;
+
+				Height = String::To<T_>(&str[s-str.begin()]);
+			}
 		}
 		
 		

mercurial