Avoid crashing on empty files
This commit is contained in:
parent
9c375f2970
commit
fdeaf6a651
|
@ -1,5 +1,5 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
/* Copyright (c) 2009 Pierre Pronchery <khorben@defora.org> */
|
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */
|
||||||
/* This file is part of DeforaOS Unix utils */
|
/* This file is part of DeforaOS Unix utils */
|
||||||
/* This program is free software: you can redistribute it and/or modify
|
/* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -116,7 +116,7 @@ static int _tail_do_lines(Prefs * prefs, FILE * fp, char const * filename)
|
||||||
lines[pos][column] = '\0';
|
lines[pos][column] = '\0';
|
||||||
column = 0;
|
column = 0;
|
||||||
}
|
}
|
||||||
/* FIXME crashes if directly EOF */
|
if(lines[0] != NULL)
|
||||||
_lines_print(lines, pos);
|
_lines_print(lines, pos);
|
||||||
if(c != EOF || !feof(fp))
|
if(c != EOF || !feof(fp))
|
||||||
ret = _tail_error(filename, 1);
|
ret = _tail_error(filename, 1);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user