Enable WASI feature, enhance security and add SGX sample (#142)

Change emcc to clang
Refine interpreter to improve perforamnce
This commit is contained in:
Weining
2019-11-20 21:16:36 +08:00
committed by wenyongh
parent 29c7c743e9
commit 27f246b5f3
159 changed files with 9543 additions and 3789 deletions

View File

@ -88,7 +88,8 @@ CJSON_PUBLIC(char *) cJSON_GetStringValue(cJSON *item) {
CJSON_PUBLIC(const char*) cJSON_Version(void)
{
static char version[15];
sprintf(version, "%i.%i.%i", CJSON_VERSION_MAJOR, CJSON_VERSION_MINOR, CJSON_VERSION_PATCH);
snprintf(version, sizeof(version), "%i.%i.%i",
CJSON_VERSION_MAJOR, CJSON_VERSION_MINOR, CJSON_VERSION_PATCH);
return version;
}
@ -446,20 +447,20 @@ static cJSON_bool print_number(const cJSON * const item,
/* This checks for NaN and Infinity */
if ((d * 0) != 0) {
length = sprintf((char*) number_buffer, "null");
length = snprintf((char*) number_buffer, sizeof(number_buffer), "null");
} else {
/* Try 15 decimal places of precision to avoid nonsignificant nonzero digits */
length = sprintf((char*) number_buffer, "%1.15g", d);
length = snprintf((char*) number_buffer, sizeof(number_buffer), "%1.15g", d);
/* Check whether the original double can be recovered */
if ((sscanf((char*) number_buffer, "%lg", &test) != 1)
|| ((double) test != d)) {
/* If not, print with 17 decimal places of precision */
length = sprintf((char*) number_buffer, "%1.17g", d);
length = snprintf((char*) number_buffer, sizeof(number_buffer), "%1.17g", d);
}
}
/* sprintf failed or buffer overrun occured */
/* snprintf failed or buffer overrun occured */
if ((length < 0) || (length > (int) (sizeof(number_buffer) - 1))) {
return false;
}
@ -748,7 +749,7 @@ static cJSON_bool print_string_ptr(const unsigned char * const input,
printbuffer * const output_buffer)
{
const unsigned char *input_pointer = NULL;
unsigned char *output = NULL;
unsigned char *output = NULL, *output_end;
unsigned char *output_pointer = NULL;
size_t output_length = 0;
/* numbers of additional characters needed for escaping */
@ -796,6 +797,7 @@ static cJSON_bool print_string_ptr(const unsigned char * const input,
if (output == NULL) {
return false;
}
output_end = output + output_length + sizeof("\"\"");
/* no characters have to be escaped */
if (escape_characters == 0) {
@ -843,7 +845,8 @@ static cJSON_bool print_string_ptr(const unsigned char * const input,
break;
default:
/* escape and print as unicode codepoint */
sprintf((char*) output_pointer, "u%04x", *input_pointer);
snprintf((char*) output_pointer, output_end - output_pointer,
"u%04x", *input_pointer);
output_pointer += 4;
break;
}