]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Handle potential malloc failure better
authorTravis Cross <tc@traviscross.com>
Tue, 28 May 2013 03:40:58 +0000 (03:40 +0000)
committerTravis Cross <tc@traviscross.com>
Wed, 29 May 2013 02:51:51 +0000 (02:51 +0000)
libs/esl/src/esl_json.c

index 90688d057ccb6d4a8c23911cdb872ab2a5ba3e34..11a3640c4292acf8aa2b16beb7ced3130565f70b 100644 (file)
@@ -523,10 +523,10 @@ ESL_DECLARE(cJSON *)cJSON_CreateArray(void)                                               {cJSON *item=cJSON_New_Item();i
 ESL_DECLARE(cJSON *)cJSON_CreateObject(void)                                           {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_Object;return item;}
 
 /* Create Arrays: */
-ESL_DECLARE(cJSON *)cJSON_CreateIntArray(int *numbers,int count)                               {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a!=0 && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
-ESL_DECLARE(cJSON *)cJSON_CreateFloatArray(float *numbers,int count)                   {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a!=0 && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
-ESL_DECLARE(cJSON *)cJSON_CreateDoubleArray(double *numbers,int count)         {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a!=0 && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
-ESL_DECLARE(cJSON *)cJSON_CreateStringArray(const char **strings,int count)    {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a!=0 && i<count;i++){n=cJSON_CreateString(strings[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
+ESL_DECLARE(cJSON *)cJSON_CreateIntArray(int *numbers,int count)                               {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a!=0 && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!n)return 0;if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
+ESL_DECLARE(cJSON *)cJSON_CreateFloatArray(float *numbers,int count)                   {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a!=0 && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!n)return 0;if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
+ESL_DECLARE(cJSON *)cJSON_CreateDoubleArray(double *numbers,int count)         {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a!=0 && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!n)return 0;if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
+ESL_DECLARE(cJSON *)cJSON_CreateStringArray(const char **strings,int count)    {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a!=0 && i<count;i++){n=cJSON_CreateString(strings[i]);if(!n)return 0;if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
 
 /* For Emacs:
  * Local Variables: