1
0
Fork 0

Fix recently introduced bug in json-to-prop conversion

This commit is contained in:
Torsten Dreyer 2015-03-11 16:59:58 +01:00
parent fced50f480
commit f32f1fba59

View file

@ -118,15 +118,12 @@ void JSON::toProp(cJSON * json, SGPropertyNode_ptr base)
// else update base
cJSON * cj = cJSON_GetObjectItem(json, "name");
if ( cj ) {
char * name = cj->valuestring;
if (NULL == name) return; // no name?
string namestr = simgear::strutils::strip(string(name));
if( namestr.empty() )
return;
const char * name = cj->valuestring;
if (NULL == name) name = "";
//TODO: better check for valid name
string namestr = simgear::strutils::strip(string(name));
if( false == namestr.empty() ) {
int index = 0;
cj = cJSON_GetObjectItem(json, "index");
if (NULL != cj) index = cj->valueint;
@ -134,6 +131,7 @@ void JSON::toProp(cJSON * json, SGPropertyNode_ptr base)
n = base->getNode(namestr, index, true);
}
}
cJSON * children = cJSON_GetObjectItem(json, "children");
if (NULL != children) {