commit bf11ce0ed8ce52b06bf5fb9367e7951e447c8c42 from: Stefan Sperling date: Tue Sep 22 22:26:33 2020 UTC update arraylist's allocated counter only if the allocation succeeds commit - ab528e220f57a9cc557919a18aca8d39327ad207 commit + bf11ce0ed8ce52b06bf5fb9367e7951e447c8c42 blob - badedfc28278523e489b303c0c470e925bbbabfa blob + 9aa063040f234dd19ec987202fad2d6f68260079 --- include/diff/arraylist.h +++ include/diff/arraylist.h @@ -60,16 +60,17 @@ } \ if ((ARRAY_LIST).head == NULL \ || (ARRAY_LIST).allocated < (ARRAY_LIST).len + 1) { \ - (ARRAY_LIST).allocated += \ - (ARRAY_LIST).alloc_blocksize ? : 8; \ (ARRAY_LIST).p = recallocarray((ARRAY_LIST).head, \ (ARRAY_LIST).len, \ - (ARRAY_LIST).allocated, \ + (ARRAY_LIST).allocated + \ + (ARRAY_LIST).alloc_blocksize ? : 8, \ sizeof(*(ARRAY_LIST).head)); \ if ((ARRAY_LIST).p == NULL) { \ NEW_ITEM_P = NULL; \ break; \ } \ + (ARRAY_LIST).allocated += \ + (ARRAY_LIST).alloc_blocksize ? : 8; \ (ARRAY_LIST).head = (ARRAY_LIST).p; \ (ARRAY_LIST).p = NULL; \ }; \