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:
parent
4ace424fa7
commit
8a080be4ad
|
@ -829,6 +829,11 @@ static int is_last_line(FILE *stream)
|
||||||
|
|
||||||
/* check if we're sending the last line */
|
/* check if we're sending the last line */
|
||||||
pos = ftell(stream);
|
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)) {
|
if (!fgets(next_seg_buf, sizeof(next_seg_buf)-2, stream)) {
|
||||||
fseek(stream, pos, SEEK_SET);
|
fseek(stream, pos, SEEK_SET);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in New Issue