Azure IoT common library

Dependents:   STM32F746_iothub_client_sample_mqtt f767zi_mqtt iothub_client_sample_amqp iothub_client_sample_http ... more

Revision:
6:c55b013dfc2a
Parent:
0:fa2de1b79154
Child:
7:1af47e3a19b6
--- a/crt_abstractions.c	Fri Jun 17 17:03:29 2016 -0700
+++ b/crt_abstractions.c	Fri Jul 01 10:43:23 2016 -0700
@@ -264,14 +264,16 @@
     else
     {
         size_t l = strlen(source);
-        *destination = (char*)malloc(l + 1);
+        char* temp = (char*)malloc(l + 1);
+        
         /*Codes_SRS_CRT_ABSTRACTIONS_99_037: [Upon failure to allocate memory for the destination, the function will return ENOMEM.]*/
-        if (*destination == NULL)
+        if (temp == NULL)
         {
             result = ENOMEM;
         }
         else
         {
+            *destination = temp;
             /*Codes_SRS_CRT_ABSTRACTIONS_99_039: [mallocAndstrcpy_s shall copy the contents in the address source, including the terminating null character into location specified by the destination pointer after the memory allocation.]*/
             int temp = strcpy_s(*destination, l + 1, source);
             if (temp < 0) /*strcpy_s error*/