Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
be sure that we don't try to read bytes after the end of the file
[simgrid.git] / src / surf / storage_n11.cpp
index 8fc1ede..42fef37 100644 (file)
@@ -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){
 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
     fd->current_position = fd->size;
   }
   else