[haiku-commits] Re: r39785 - in haiku/trunk/src/apps/debugger/value: type_handlers value_nodes

  • From: Ingo Weinhold <ingo_weinhold@xxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 09 Dec 2010 16:53:03 +0100

On 2010-12-09 at 05:28:11 [+0100], anevilyak@xxxxxxxxx wrote:
> Author: anevilyak
> Date: 2010-12-09 05:28:10 +0100 (Thu, 09 Dec 2010)
> New Revision: 39785
> Changeset: http://dev.haiku-os.org/changeset/39785
> 
> Modified:
>    haiku/trunk/src/apps/debugger/value/type_handlers/CStringTypeHandler.cpp
>    haiku/trunk/src/apps/debugger/value/value_nodes/CStringValueNode.cpp
>    haiku/trunk/src/apps/debugger/value/value_nodes/CStringValueNode.h
> Log:
> Modify the CString type/value handlers to accept character arrays as well as
> character pointers.
> 
> 
> 
> Modified: 
> haiku/trunk/src/apps/debugger/value/type_handlers/CStringTypeHandler.cpp
> ===================================================================
> --- 
> haiku/trunk/src/apps/debugger/value/type_handlers/CStringTypeHandler.cpp    
> 2010-12-09 00:40:25 UTC (rev 39784)
> +++ 
> haiku/trunk/src/apps/debugger/value/type_handlers/CStringTypeHandler.cpp    
> 2010-12-09 04:28:10 UTC (rev 39785)
> @@ -23,28 +23,39 @@
>  CStringTypeHandler::SupportsType(Type* type)
>  {
>      AddressType* addressType = dynamic_cast<AddressType*>(type);
> +    ArrayType* arrayType = dynamic_cast<ArrayType*>(type);
> +    PrimitiveType* baseType = NULL;
> +    ModifiedType* modifiedType = NULL;
>      if (addressType != NULL && addressType->AddressKind()
> -            == DERIVED_TYPE_POINTER) {
> -        PrimitiveType* baseType = dynamic_cast<PrimitiveType*>(
> -            addressType->BaseType());
> -
> +        == DERIVED_TYPE_POINTER) {

The indentation was more correct before.

[...]
> @@ -56,10 +67,8 @@
>      if (SupportsType(type) == 0.0f)
>          return B_BAD_VALUE;
>  
> -    AddressType* supportedType = dynamic_cast<AddressType*>(type);
> -
>      ValueNode* node = new(std::nothrow) CStringValueNode(nodeChild,
> -        supportedType);
> +        type);

I would also pass the array size and use that as an additional limitation of 
the length of the string to be read. This will restrict the potential amount 
of garbage shown before the array is initialized or in case it doesn't 
actually contain a null-terminated string.

CU, Ingo

Other related posts: