vfs: check userland buffers before reading them.
[haiku.git] / src / kits / debugger / value / value_nodes / PointerToMemberValueNode.cpp
blob21a02daa8374c17674ca67048bd99096f19f1043
1 /*
2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
7 #include "PointerToMemberValueNode.h"
9 #include <new>
11 #include "Architecture.h"
12 #include "IntegerValue.h"
13 #include "Tracing.h"
14 #include "Type.h"
15 #include "ValueLoader.h"
16 #include "ValueLocation.h"
19 PointerToMemberValueNode::PointerToMemberValueNode(ValueNodeChild* nodeChild,
20 PointerToMemberType* type)
22 ChildlessValueNode(nodeChild),
23 fType(type)
25 fType->AcquireReference();
29 PointerToMemberValueNode::~PointerToMemberValueNode()
31 fType->ReleaseReference();
35 Type*
36 PointerToMemberValueNode::GetType() const
38 return fType;
42 status_t
43 PointerToMemberValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader,
44 ValueLocation*& _location, Value*& _value)
46 // get the location
47 ValueLocation* location = NodeChild()->Location();
48 if (location == NULL)
49 return B_BAD_VALUE;
51 TRACE_LOCALS(" TYPE_POINTER_TO_MEMBER\n");
53 // get the value type
54 type_code valueType;
55 if (valueLoader->GetArchitecture()->AddressSize() == 4) {
56 valueType = B_UINT32_TYPE;
57 TRACE_LOCALS(" -> 32 bit\n");
58 } else {
59 valueType = B_UINT64_TYPE;
60 TRACE_LOCALS(" -> 64 bit\n");
63 // load the value data
64 BVariant valueData;
65 status_t error = valueLoader->LoadValue(location, valueType, false,
66 valueData);
67 if (error != B_OK)
68 return error;
70 // create the type object
71 Value* value = new(std::nothrow) IntegerValue(valueData);
72 if (value == NULL)
73 return B_NO_MEMORY;
75 location->AcquireReference();
76 _location = location;
77 _value = value;
78 return B_OK;