From 47eb44ba902ff28a13479d1d9152f9899ec7a759 Mon Sep 17 00:00:00 2001 From: suhyung Eom Date: Thu, 11 Jun 2015 19:07:52 +0900 Subject: [PATCH] Fixed prevent defects < Prevent message > Dereference null return value (NULL_RETURNS) Signed-off-by: suhyung Eom Change-Id: Id84d90dcb1adca17b3fdc4f3b01ac86748306eab --- dali/internal/event/render-tasks/render-task-impl.cpp | 12 ++++++++---- .../internal/update/modeling/scene-graph-animatable-mesh.cpp | 1 + dali/public-api/common/dali-vector.cpp | 2 ++ dali/public-api/common/stage.cpp | 4 +++- dali/public-api/images/buffer-image.cpp | 5 ++++- dali/public-api/object/property-value.cpp | 2 +- 6 files changed, 19 insertions(+), 7 deletions(-) diff --git a/dali/internal/event/render-tasks/render-task-impl.cpp b/dali/internal/event/render-tasks/render-task-impl.cpp index ff8c400..926354f 100644 --- a/dali/internal/event/render-tasks/render-task-impl.cpp +++ b/dali/internal/event/render-tasks/render-task-impl.cpp @@ -224,10 +224,14 @@ void RenderTask::GetViewport( Viewport& viewPort ) const } else { - Vector2 size( Stage::GetCurrent()->GetSize() ); - viewPort.x = viewPort.y = 0; - viewPort.width = size.width; - viewPort.height = size.height; + Internal::Stage* stage = Internal::Stage::GetCurrent(); + if ( stage ) + { + Vector2 size( stage->GetSize() ); + viewPort.x = viewPort.y = 0; + viewPort.width = size.width; + viewPort.height = size.height; + } } } else diff --git a/dali/internal/update/modeling/scene-graph-animatable-mesh.cpp b/dali/internal/update/modeling/scene-graph-animatable-mesh.cpp index 1d73b7d..e3e7d24 100644 --- a/dali/internal/update/modeling/scene-graph-animatable-mesh.cpp +++ b/dali/internal/update/modeling/scene-graph-animatable-mesh.cpp @@ -65,6 +65,7 @@ void AnimatableMesh::UpdateMesh( BufferIndex updateBufferIndex ) { // Copy properties to associated scenegraph mesh SceneGraph::Mesh* mesh(mResourceManager.GetMesh(mMeshId)); + DALI_ASSERT_DEBUG( mesh ); // TODO: Should be double buffered - pass in buffer index MeshData& meshData = mesh->GetMeshData(Mesh::UPDATE_THREAD); diff --git a/dali/public-api/common/dali-vector.cpp b/dali/public-api/common/dali-vector.cpp index fec1b2a..084515e 100644 --- a/dali/public-api/common/dali-vector.cpp +++ b/dali/public-api/common/dali-vector.cpp @@ -76,6 +76,8 @@ void VectorBase::Reserve( SizeType capacity, SizeType elementSize ) { const SizeType wholeAllocation = sizeof(SizeType) * 2u + capacity * elementSize; void* wholeData = (void*)malloc( wholeAllocation ); + DALI_ASSERT_ALWAYS( wholeData && "VectorBase::Reserve - Memory allocation failed" ); + #if defined( DEBUG_ENABLED ) // in debug build this will help identify a vector of uninitialized data memset( wholeData, 0xaa, wholeAllocation ); diff --git a/dali/public-api/common/stage.cpp b/dali/public-api/common/stage.cpp index 99d3c66..9a1e43f 100644 --- a/dali/public-api/common/stage.cpp +++ b/dali/public-api/common/stage.cpp @@ -122,8 +122,10 @@ Vector2 Stage::GetDpi() const ObjectRegistry Stage::GetObjectRegistry() const { - Internal::ObjectRegistry& internal = Internal::Stage::GetCurrent()->GetObjectRegistry(); + Internal::Stage* stage = Internal::Stage::GetCurrent(); + DALI_ASSERT_ALWAYS( stage && "GetObjectRegistry() : Stage is null" ); + Internal::ObjectRegistry& internal = stage->GetObjectRegistry(); return ObjectRegistry(&internal); } diff --git a/dali/public-api/images/buffer-image.cpp b/dali/public-api/images/buffer-image.cpp index 1881a14..1bd44f5 100644 --- a/dali/public-api/images/buffer-image.cpp +++ b/dali/public-api/images/buffer-image.cpp @@ -59,7 +59,10 @@ const BufferImage BufferImage::WHITE() { Internal::BufferImage* internal = new Internal::BufferImage(1,1,Pixel::RGBA8888, Dali::Image::NEVER); PixelBuffer* pBuf = internal->GetBuffer(); - pBuf[0] = pBuf[1] = pBuf[2] = pBuf[3] = 0xFF; + if ( pBuf ) + { + pBuf[0] = pBuf[1] = pBuf[2] = pBuf[3] = 0xFF; + } return BufferImage(internal); } diff --git a/dali/public-api/object/property-value.cpp b/dali/public-api/object/property-value.cpp index afa78c4..bb347ab 100644 --- a/dali/public-api/object/property-value.cpp +++ b/dali/public-api/object/property-value.cpp @@ -870,7 +870,7 @@ Property::Value& Property::Value::GetItem(const int index, std::string& key) con if( Property::MAP == GetType() ) { Property::Map *container = AnyCast(&(mImpl->mValue)); - if( index < static_cast(container->Count()) ) + if( container && index < static_cast(container->Count()) ) { key = container->GetKey( index ); } -- 2.7.4