• J
    pack-objects: avoid reading uninitalized data · 421b488a
    Jeff King 提交于
    In the main loop of find_deltas, we do:
    
      struct object_entry *entry = *list++;
      ...
      if (!*list_size)
    	  ...
    	  break
    
    Because we look at and increment *list _before_ the check of
    list_size, in the very last iteration of the loop we will
    look at uninitialized data, and increment the pointer beyond
    one past the end of the allocated space. Since we don't
    actually do anything with the data until after the check,
    this is not a problem in practice.
    
    But since it technically violates the C standard, and
    because it provokes a spurious valgrind warning, let's just
    move the initialization of entry to a safe place.
    
    This fixes valgrind errors in t5300, t5301, t5302, t303, and
    t9400.
    Signed-off-by: NJeff King <peff@peff.net>
    Signed-off-by: NJunio C Hamano <gitster@pobox.com>
    421b488a
builtin-pack-objects.c 56.4 KB