Revision 421b488a58fea89ceb55d5b358738e9251d44f5e authored by Jeff King on 23 October 2008, 04:31:03 UTC, committed by Junio C Hamano on 02 November 2008, 06:46:40 UTC
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: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 13494ed
Raw File
t0023-crlf-am.sh
#!/bin/sh

test_description='Test am with auto.crlf'

. ./test-lib.sh

cat >patchfile <<\EOF
From 38be10072e45dd6b08ce40851e3fca60a31a340b Mon Sep 17 00:00:00 2001
From: Marius Storm-Olsen <x@y.com>
Date: Thu, 23 Aug 2007 13:00:00 +0200
Subject: test1

---
 foo |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 foo

diff --git a/foo b/foo
new file mode 100644
index 0000000000000000000000000000000000000000..5716ca5987cbf97d6bb54920bea6adde242d87e6
--- /dev/null
+++ b/foo
@@ -0,0 +1 @@
+bar
EOF

test_expect_success 'setup' '

	git config core.autocrlf true &&
	echo foo >bar &&
	git add bar &&
	test_tick &&
	git commit -m initial

'

test_expect_success 'am' '

	git am -3 <patchfile &&
	git diff-files --name-status --exit-code

'

test_done
back to top