Fix deFile_getSize.
authorMika Isojärvi <misojarvi@google.com>
Mon, 2 Nov 2015 22:26:28 +0000 (14:26 -0800)
committerMika Isojärvi <misojarvi@google.com>
Mon, 2 Nov 2015 23:36:16 +0000 (15:36 -0800)
Seek to the end of the file instead of second last byte of the file.

Change-Id: I2cdb6db50d4b0d3b73ea83edfedaf1645b766808

framework/delibs/deutil/deFile.c

index 3cd1265..1587a1d 100644 (file)
@@ -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;