Browse Source

Fix some errors found by automated code checker "cppcheck"

- Add missing field initializations to constructors.
- Fix case of pointer dereference before NULL check.
Victor Luchitz 13 years ago
parent
commit
a362d43464
2 changed files with 8 additions and 3 deletions
  1. 7 3
      Source/Core/LayoutEngine.cpp
  2. 1 0
      Source/Core/WidgetSlider.cpp

+ 7 - 3
Source/Core/LayoutEngine.cpp

@@ -48,6 +48,7 @@ struct LayoutChunk
 {
 {
 	LayoutChunk()
 	LayoutChunk()
 	{
 	{
+		memset(buffer, 0, size);
 	}
 	}
 
 
 	static const unsigned int size = MAX(sizeof(LayoutBlockBox), MAX(sizeof(LayoutInlineBox), MAX(sizeof(LayoutInlineBoxText), MAX(sizeof(LayoutLineBox), sizeof(LayoutBlockBoxSpace)))));
 	static const unsigned int size = MAX(sizeof(LayoutBlockBox), MAX(sizeof(LayoutInlineBox), MAX(sizeof(LayoutInlineBoxText), MAX(sizeof(LayoutLineBox), sizeof(LayoutBlockBoxSpace)))));
@@ -561,15 +562,18 @@ void LayoutEngine::BuildBoxHeight(Box& box, Element* element, float containing_b
 	else
 	else
 	{
 	{
 		const Property* height_property = element->GetProperty(HEIGHT);
 		const Property* height_property = element->GetProperty(HEIGHT);
-		if (height_property->unit == Property::KEYWORD)
+		if (height_property == NULL)
+		{
+			height_auto = false;		
+		}
+		else if (height_property->unit == Property::KEYWORD)
 		{
 		{
 			height_auto = true;
 			height_auto = true;
 		}
 		}
 		else
 		else
 		{
 		{
 			height_auto = false;
 			height_auto = false;
-			if (height_property != NULL)
-				content_area.y = element->ResolveProperty(HEIGHT, containing_block_height);
+			content_area.y = element->ResolveProperty(HEIGHT, containing_block_height);
 		}
 		}
 	}
 	}
 
 

+ 1 - 0
Source/Core/WidgetSlider.cpp

@@ -52,6 +52,7 @@ WidgetSlider::WidgetSlider(Element* _parent)
 	arrows[1] = NULL;
 	arrows[1] = NULL;
 
 
 	bar_position = 0;
 	bar_position = 0;
+	bar_drag_anchor = 0;
 
 
 	arrow_timers[0] = -1;
 	arrow_timers[0] = -1;
 	arrow_timers[1] = -1;
 	arrow_timers[1] = -1;