From db47f7bec9a8c821125bda2d6cb27626e12e7fa7 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Fri, 25 Sep 2015 16:05:48 +0200 Subject: [PATCH 1/1] be sure that we don't try to read bytes after the end of the file --- src/surf/storage_n11.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/surf/storage_n11.cpp b/src/surf/storage_n11.cpp index 8fc1edec8b..42fef37138 100644 --- a/src/surf/storage_n11.cpp +++ b/src/surf/storage_n11.cpp @@ -433,7 +433,11 @@ StorageAction *StorageN11::close(surf_file_t fd) StorageAction *StorageN11::read(surf_file_t fd, sg_size_t size) { if(fd->current_position + size > fd->size){ - size = fd->size - fd->current_position; + if (fd->current_position > fd->size){ + size = 0; + } else { + size = fd->size - fd->current_position; + } fd->current_position = fd->size; } else -- 2.20.1