[Libreoffice-commits] libexttextcat.git: src/fingerprint.c

Mark Wielaard mark at klomp.org
Sun Jun 9 22:02:19 PDT 2013


 src/fingerprint.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 18b843fccda2ba452673290965dfe69ff8ce6445
Author: Mark Wielaard <mark at klomp.org>
Date:   Sat Jun 8 23:57:16 2013 +0200

    Don't use overlapping memcpy in heapextract.
    
    Calling memcpy with source and destination overlapping might result in
    unexpected results. In this case it was also useless since it was trying
    to copy an element that was going to be removed immediately afterwards.
    
    Change-Id: I20852eed68aaf956c8597442a986d37ff21e106a
    Reviewed-on: https://gerrit.libreoffice.org/4202
    Reviewed-by: David Tardon <dtardon at redhat.com>
    Tested-by: David Tardon <dtardon at redhat.com>

diff --git a/src/fingerprint.c b/src/fingerprint.c
index e17d83e..428b8df 100644
--- a/src/fingerprint.c
+++ b/src/fingerprint.c
@@ -254,7 +254,8 @@ static int heapextract(table_t * t, entry_t * item)
     p = &(t->heap[0]);
 
     memcpy(item, p, sizeof(entry_t));
-    memcpy(&(t->heap[0]), &(t->heap[t->size - 1]), sizeof(entry_t));
+    if (t->size > 1)
+        memcpy(&(t->heap[0]), &(t->heap[t->size - 1]), sizeof(entry_t));
 
     siftdown(t, t->size, 0);
     t->size--;


More information about the Libreoffice-commits mailing list