diff --git a/cJSON.c b/cJSON.c index 31c43dd2e90ca16365cf88c5c4ecea923ecb158b..0ce5f08ccf8b3c7e76712cee49513dbcd26b6613 100644 --- a/cJSON.c +++ b/cJSON.c @@ -122,7 +122,16 @@ static char *print_number(cJSON *item) if (fabs(((double)item->valueint)-d)<=DBL_EPSILON && d<=INT_MAX && d>=INT_MIN) { str=(char*)cJSON_malloc(21); /* 2^64+1 can be represented in 21 chars. */ - if (str) sprintf(str,"%d",item->valueint); + if (str) + { + int i,j,t; + + if (d<0) t=-d; else t=d; + for (i=0;t>0;t/=10) str[i++]='0'+(t%10); + if (d<0) str[i++]='-'; + str[i--]=0; + for (j=0;j