Ticket #2861: additional error handling in edit_save_block().

If edit->column_highlight is on and the disk is so full that the editor
is unable even to write the magic (r <= 0), then subsequent if (len)
check might fail, since the value of len is undefined.

The solution is to initialize len with a non-zero value, so that the
function properly returns an error value in all cases (adding an
explicit return 0; is also possible, but then one must take care of
closing file descriptors, which is less convenient).

Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
This commit is contained in:
Yury V. Zaytsev 2012-08-04 18:55:07 +02:00 committed by Slava Zanko
parent 8e224507c1
commit fbc013421c
1 changed files with 1 additions and 1 deletions

View File

@ -2919,7 +2919,7 @@ edit_ok_to_exit (WEdit * edit)
gboolean
edit_save_block (WEdit * edit, const char *filename, off_t start, off_t finish)
{
int len, file;
int len = 1, file;
vfs_path_t *vpath;
vpath = vfs_path_from_str (filename);