From 8b3904dfb79ddbb71988439d3604ed32d17daf8c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mika=20Isoj=C3=A4rvi?= Date: Mon, 2 Nov 2015 14:26:28 -0800 Subject: [PATCH] Fix deFile_getSize. Seek to the end of the file instead of second last byte of the file. Change-Id: I2cdb6db50d4b0d3b73ea83edfedaf1645b766808 --- framework/delibs/deutil/deFile.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/framework/delibs/deutil/deFile.c b/framework/delibs/deutil/deFile.c index 3cd1265..1587a1d 100644 --- a/framework/delibs/deutil/deFile.c +++ b/framework/delibs/deutil/deFile.c @@ -164,10 +164,11 @@ deInt64 deFile_getSize (const deFile* file) if (curPos < 0) return -1; - if (lseek(file->fd, -1, SEEK_END) < 0) + size = lseek(file->fd, 0, SEEK_END); + + if (size < 0) return -1; - size = lseek(file->fd, 0, SEEK_CUR); lseek(file->fd, (off_t)curPos, SEEK_SET); return size; -- 2.7.4