summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/erec.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/erec.c b/src/erec.c
index 501bf4b6..554a406c 100644
--- a/src/erec.c
+++ b/src/erec.c
@@ -78,7 +78,7 @@ void erec_print(FILE *f, const struct error_record *erec)
const char *line = NULL; /* silence gcc */
char buf[1024];
unsigned int i, end;
- int l;
+ int l, ret;
switch (indesc->type) {
case INDESC_BUFFER:
@@ -88,8 +88,9 @@ void erec_print(FILE *f, const struct error_record *erec)
case INDESC_FILE:
memset(buf, 0, sizeof(buf));
lseek(indesc->fd, loc->line_offset, SEEK_SET);
- read(indesc->fd, buf, sizeof(buf) - 1);
- *strchrnul(buf, '\n') = '\0';
+ ret = read(indesc->fd, buf, sizeof(buf) - 1);
+ if (ret > 0)
+ *strchrnul(buf, '\n') = '\0';
line = buf;
break;
case INDESC_INTERNAL: