Clear the user_partition_data::user_data fields before updating the

BPartition structure with the data retrieved from the kernel. For new
partitions the field is not set in the next step and later code would
use an initialized pointer.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22471 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2007-10-07 14:56:26 +00:00
parent 7ede8e4494
commit 04adb291a6
2 changed files with 19 additions and 1 deletions

View File

@ -52,6 +52,8 @@ private:
status_t _Update(bool shadow, bool *updated);
status_t _Update(user_disk_device_data *data, bool *updated);
static void _ClearUserData(user_partition_data* data);
virtual bool _AcceptVisitor(BDiskDeviceVisitor *visitor, int32 level);
user_disk_device_data *fDeviceData;

View File

@ -377,11 +377,16 @@ BDiskDevice::_Update(user_disk_device_data *data, bool *updated)
if (!updated)
updated = &_updated;
*updated = false;
// clear the user_data fields first
_ClearUserData(&data->device_partition_data);
// remove obsolete partitions
status_t error = _RemoveObsoleteDescendants(&data->device_partition_data,
updated);
updated);
if (error != B_OK)
return error;
// update existing partitions and add new ones
error = BPartition::_Update(&data->device_partition_data, updated);
if (error == B_OK) {
@ -404,3 +409,14 @@ BDiskDevice::_AcceptVisitor(BDiskDeviceVisitor *visitor, int32 level)
return visitor->Visit(this);
}
// _ClearUserData
void
BDiskDevice::_ClearUserData(user_partition_data* data)
{
data->user_data = NULL;
// recurse
for (int i = 0; i < data->child_count; i++)
_ClearUserData(data->children[i]);
}