ecere/sys/JSON: Fixed crash on unknown member
authorJerome St-Louis <jerome@ecere.com>
Fri, 20 Mar 2015 06:02:12 +0000 (02:02 -0400)
committerJerome St-Louis <jerome@ecere.com>
Thu, 15 Oct 2015 00:19:37 +0000 (20:19 -0400)
- Also fixed strtol warnings on Linux

ecere/src/sys/JSON.ec

index e9f9f1b..45b8794 100644 (file)
@@ -650,6 +650,7 @@ public:
       }
       buffer[c] = 0;
       //if(strchr(buffer, '.'))
+      if(!type) return success;
 
       // TOFIX: How to swiftly handle classes with base data type?
       if(type == class(double) || !strcmp(type.dataTypeString, "double"))
@@ -676,12 +677,12 @@ public:
       }
       else if(type == class(uint) || !strcmp(type.dataTypeString, "unsigned int"))
       {
-         value.ui = strtoul(buffer, null, 10);  // TOFIX: 64 bit support
+         value.ui = (uint)strtoul(buffer, null, 10);  // TOFIX: 64 bit support
          result = success;
       }
       else
       {
-         value.i = strtol(buffer, null, 10);
+         value.i = (int)strtol(buffer, null, 10);
          result = success;
       }