Do not re-alloc memory in library implementation of ecrt_sdo_request_state(). stable-1.5
authorFlorian Pose <fp@igh-essen.com>
Thu, 20 Sep 2012 09:12:03 +0200
branchstable-1.5
changeset 2431 eee9ed9901f7
parent 2430 1430a47a67dd
child 2432 f4313f5aba88
Do not re-alloc memory in library implementation of ecrt_sdo_request_state().
lib/sdo_request.c
--- a/lib/sdo_request.c	Wed Sep 19 22:49:38 2012 +0200
+++ b/lib/sdo_request.c	Thu Sep 20 09:12:03 2012 +0200
@@ -101,16 +101,9 @@
 
     if (data.size) { // new data waiting to be copied
         if (req->mem_size < data.size) {
-            if (req->data)
-                free(req->data);
-            req->data = malloc(data.size);
-            if (!req->data) {
-                req->mem_size = 0;
-                fprintf(stderr, "Failed to allocate %u bytes of SDO data"
-                        " memory!\n", data.size);
-                return EC_REQUEST_ERROR;
-            }
-            req->mem_size = data.size;
+            fprintf(stderr, "Received %u bytes do not fit info SDO data"
+                    " memory (%u bytes)!\n", data.size, req->mem_size);
+            return EC_REQUEST_ERROR;
         }
 
         data.data = req->data;