* 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:
Vendored
+5
-3
@@ -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.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -280,13 +280,15 @@ FileMap::_InvalidateAfter(off_t offset)
|
|||||||
uint32 index;
|
uint32 index;
|
||||||
file_extent* extent = _FindExtent(offset, &index);
|
file_extent* extent = _FindExtent(offset, &index);
|
||||||
if (extent != NULL) {
|
if (extent != NULL) {
|
||||||
_MakeSpace(index + 1);
|
uint32 resizeTo = index + 1;
|
||||||
|
|
||||||
if (extent->offset + extent->disk.length > offset) {
|
if (extent->offset + extent->disk.length > offset) {
|
||||||
extent->disk.length = offset - extent->offset;
|
extent->disk.length = offset - extent->offset;
|
||||||
if (extent->disk.length == 0)
|
if (extent->disk.length == 0)
|
||||||
_MakeSpace(index);
|
resizeTo = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_MakeSpace(resizeTo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user