THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

Browse Source

diff-delta: set size out-parameter to 0 for NULL delta

When we cannot generate a delta, we return NULL but leave delta_size
untouched. This is generally OK, as callers rely on NULL to decide if
the output is usable or not. But it can confuse compilers; in
particular, gcc 9.2.1 with "-flto -O3" complains in fast-import's
store_object() that delta_len may be used uninitialized.

Let's change the diff-delta code to set the size explicitly to 0 for a
NULL return. That silences the compiler and makes it easier to reason
about the result.

Reported-by: Stephan Beyer <s-beyer@gmx.net>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
tags/v2.24.0-rc0
Jeff King Junio C Hamano 2 months ago
parent
commit
e4b369069e
1 changed files with 2 additions and 0 deletions
  1. +2
    -0
      diff-delta.c

+ 2
- 0
diff-delta.c View File

@@ -326,6 +326,8 @@ create_delta(const struct delta_index *index,
const unsigned char *ref_data, *ref_top, *data, *top;
unsigned char *out;

*delta_size = 0;

if (!trg_buf || !trg_size)
return NULL;



Loading…
Cancel
Save