fix incorrect memory management when loading file parts from the sync db

Fri, 24 May 2024 00:18:18 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Fri, 24 May 2024 00:18:18 +0200
changeset 820
d0cccee15a7c
parent 818
bc782cca0759
child 821
9b1e998eeac6

fix incorrect memory management when loading file parts from the sync db

dav/db.c file | annotate | diff | comparison | revisions
--- a/dav/db.c	Thu May 23 23:23:36 2024 +0200
+++ b/dav/db.c	Fri May 24 00:18:18 2024 +0200
@@ -115,7 +115,6 @@
     // TODO: rewrite using low level array
     
     CxList *parts = cxLinkedListCreateSimple(CX_STORE_POINTERS);
-    cxDefineDestructor(parts, filepart_free);
     
     FilePart *current_part = NULL;
     
@@ -166,12 +165,10 @@
     
     if(!err) {
         FilePart *file_parts = calloc(count, sizeof(FilePart));
-        size_t i = 0;
         CxIterator iter = cxListIterator(parts);
         cx_foreach(FilePart*, p, iter) {
-            file_parts[i] = *p;
+            file_parts[iter.index] = *p;
             free(p);
-            i++;
         }
         
         res->parts = file_parts;

mercurial