You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/05/17 20:51:55 UTC

[32/50] [abbrv] incubator-mynewt-core git commit: cbmem append was not considering header length

cbmem append was not considering header length


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/edc9f73b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/edc9f73b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/edc9f73b

Branch: refs/heads/master
Commit: edc9f73b02437d192fda81c387e9507e390bc346
Parents: 4d5aa14
Author: Vipul Rahane <vi...@runtime.io>
Authored: Wed May 4 13:55:30 2016 -0700
Committer: Vipul Rahane <vi...@runtime.io>
Committed: Mon May 16 13:58:53 2016 -0700

----------------------------------------------------------------------
 libs/util/src/cbmem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/edc9f73b/libs/util/src/cbmem.c
----------------------------------------------------------------------
diff --git a/libs/util/src/cbmem.c b/libs/util/src/cbmem.c
index 27dc262..a0ac332 100644
--- a/libs/util/src/cbmem.c
+++ b/libs/util/src/cbmem.c
@@ -92,7 +92,7 @@ cbmem_append(struct cbmem *cbmem, void *data, uint16_t len)
     } else {
         dst = (struct cbmem_entry_hdr *) cbmem->c_buf;
     }
-    end = (uint8_t *) dst + len;
+    end = (uint8_t *) dst + len + sizeof(*dst);
 
     /* If this item would take us past the end of this buffer, then adjust 
      * the item to the beginning of the buffer.
@@ -100,7 +100,7 @@ cbmem_append(struct cbmem *cbmem, void *data, uint16_t len)
     if (end > cbmem->c_buf_end) {
         cbmem->c_buf_cur_end = (uint8_t *) dst;
         dst = (struct cbmem_entry_hdr *) cbmem->c_buf;
-        end = (uint8_t *) dst + len;
+        end = (uint8_t *) dst + len + sizeof(*dst);
         if ((uint8_t *) cbmem->c_entry_start >= cbmem->c_buf_cur_end) {
             cbmem->c_entry_start = (struct cbmem_entry_hdr *) cbmem->c_buf;
         }