Fix segmentation Fault on 32-bit
commit22a599ea9a78086bdaebcca03a61f1d60e60fc8c
authorRamsay Jones <ramsay@ramsay1.demon.co.uk>
Sun, 15 Mar 2015 22:18:46 +0000 (15 22:18 +0000)
committerJonas Fonseca <jonas.fonseca@gmail.com>
Mon, 16 Mar 2015 00:42:30 +0000 (15 20:42 -0400)
treee442a027ec0c3771fa0550e894c0d43ab6130fe3
parentcafafe9e7dcd69157bb50d185ca13dc3f42d2873
Fix segmentation Fault on 32-bit

Tig is failing 'make test' on 32-bit systems (pretty much _every_ test
fails due to Segmentation fault), but passing just fine on (two
different) 64-bit systems.

Bisecting reveals that the problem is commit bcc44849c ("Fix user-action
prompt display regression", 11-03-2015). If this commit is reverted,
then the problem goes away. The problem is that pos is initialized to
-1, which leads to a buffer underflow in prompt_input.

[ jf: Further improve the fix to use a separate variable for tracking
  changes instead of using pos. This also fixes an issue where the prompt
  was not properly updated when the last character in the input buffer is
  deleted. ]

Signed-off-by: Jonas Fonseca <jonas.fonseca@gmail.com>
src/prompt.c