fix scripter json decode crash

This commit is contained in:
gemu2015 2020-10-03 18:30:18 +02:00
parent 006859093f
commit ef63b21d99

View File

@ -3708,6 +3708,7 @@ void esp32_beep(int32_t freq ,uint32_t len) {
#define IF_NEST 8 #define IF_NEST 8
// execute section of scripter // execute section of scripter
int16_t Run_Scripter(const char *type, int8_t tlen, char *js) { int16_t Run_Scripter(const char *type, int8_t tlen, char *js) {
int16_t retval;
if (!glob_script_mem.scriptptr) { if (!glob_script_mem.scriptptr) {
return -99; return -99;
@ -3717,12 +3718,15 @@ int16_t Run_Scripter(const char *type, int8_t tlen, char *js) {
JsonParserObject jo; JsonParserObject jo;
if (js) { if (js) {
String jss = js; // copy the string to a new buffer, not sure we can change the original buffer //String jss = js; // copy the string to a new buffer, not sure we can change the original buffer
JsonParser parser((char*)jss.c_str()); //JsonParser parser((char*)jss.c_str());
JsonParser parser(js);
jo = parser.getRootObject(); jo = parser.getRootObject();
retval = Run_script_sub(type, tlen, &jo);
} else {
retval = Run_script_sub(type, tlen, 0);
} }
return retval;
return Run_script_sub(type, tlen, &jo);
} }
int16_t Run_script_sub(const char *type, int8_t tlen, JsonParserObject *jo) { int16_t Run_script_sub(const char *type, int8_t tlen, JsonParserObject *jo) {