* Fixed a bug that let _InvalidateAfter() access already freed memory, and would

also mess up the file map, causing all sorts of file corruption.
* This fixes bug #3991 (and eventually some others).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30960 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-06-04 12:29:15 +00:00
parent 2b665ac362
commit 9ca4077700
+5 -3
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2008, Axel Dörfler, [email protected].
* Copyright 2004-2009, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License.
*/
@@ -280,13 +280,15 @@ FileMap::_InvalidateAfter(off_t offset)
uint32 index;
file_extent* extent = _FindExtent(offset, &index);
if (extent != NULL) {
_MakeSpace(index + 1);
uint32 resizeTo = index + 1;
if (extent->offset + extent->disk.length > offset) {
extent->disk.length = offset - extent->offset;
if (extent->disk.length == 0)
_MakeSpace(index);
resizeTo = index;
}
_MakeSpace(resizeTo);
}
}