abis: Check for failure of ftell

In case ftell -1 will be returned. Coverity complained that the
pos we pass to fseek might be negative. In case the ftell fails
we are at the last line for sure.

Fixes: Coverity CID 1040721
This commit is contained in:
Holger Hans Peter Freyther 2014-04-04 11:48:32 +02:00
parent 4ace424fa7
commit 8a080be4ad
1 changed files with 5 additions and 0 deletions

View File

@ -829,6 +829,11 @@ static int is_last_line(FILE *stream)
/* check if we're sending the last line */
pos = ftell(stream);
/* Did ftell fail? Then we are at the end for sure */
if (pos < 0)
return 1;
if (!fgets(next_seg_buf, sizeof(next_seg_buf)-2, stream)) {
fseek(stream, pos, SEEK_SET);
return 1;