Fix users of prefix_path() to free() only when necessary
commitbe65e7d9fbd3ae6fc097cedade2afe39805fcf4e
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>
Sat, 6 May 2006 22:02:53 +0000 (7 00:02 +0200)
committerJunio C Hamano <junkio@cox.net>
Sun, 7 May 2006 04:34:32 +0000 (6 21:34 -0700)
treea9d0e6f6d4fc4a75eecdeafc20cf60d9b94883ee
parentbd886fd3ea49b726493255d4adf5d20b31681713
Fix users of prefix_path() to free() only when necessary

Unfortunately, prefix_path() sometimes returns a newly xmalloc()ed buffer,
and in other cases it returns a substring!

For example, when calling

git update-index ./hello.txt

prefix_path() returns "hello.txt", but does not allocate a new buffer. The
original code only checked if the result of prefix_path() was different from
what was passed in, and thusly trigger a segmentation fault.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
checkout-index.c
update-index.c