Browse Source

Added allocation size safety for visual components.

David Piuva 5 years ago
parent
commit
415d2b8efd
2 changed files with 4 additions and 0 deletions
  1. 2 0
      Source/DFPSR/gui/components/Button.cpp
  2. 2 0
      Source/DFPSR/gui/components/Panel.cpp

+ 2 - 0
Source/DFPSR/gui/components/Button.cpp

@@ -68,6 +68,8 @@ static OrderedImageRgbaU8 generateButtonImage(MediaMethod imageGenerator, int pr
 void Button::generateGraphics() {
 	int width = this->location.width();
 	int height = this->location.height();
+	if (width < 1) { width = 1; }
+	if (height < 1) { height = 1; }
 	if (!this->hasImages) {
 		completeAssets();
 		this->imageUp = generateButtonImage(this->button, 0, width, height, this->color.value, this->text.value, this->font);

+ 2 - 0
Source/DFPSR/gui/components/Panel.cpp

@@ -52,6 +52,8 @@ bool Panel::isContainer() const {
 void Panel::generateGraphics() {
 	int width = this->location.width();
 	int height = this->location.height();
+	if (width < 1) { width = 1; }
+	if (height < 1) { height = 1; }
 	if (!this->hasImages) {
 		completeAssets();
 		this->background(width, height, this->color.value.red, this->color.value.green, this->color.value.blue)(this->imageBackground);