From: Frederic Suter Date: Fri, 25 Sep 2015 14:05:48 +0000 (+0200) Subject: be sure that we don't try to read bytes after the end of the file X-Git-Tag: v3_12~117^2~4 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/db47f7bec9a8c821125bda2d6cb27626e12e7fa7?ds=sidebyside be sure that we don't try to read bytes after the end of the file --- 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