浏览代码

Added allocation size safety for visual components.

David Piuva 5 年之前
父节点
当前提交
415d2b8efd
共有 2 个文件被更改,包括 4 次插入0 次删除
  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() {
 void Button::generateGraphics() {
 	int width = this->location.width();
 	int width = this->location.width();
 	int height = this->location.height();
 	int height = this->location.height();
+	if (width < 1) { width = 1; }
+	if (height < 1) { height = 1; }
 	if (!this->hasImages) {
 	if (!this->hasImages) {
 		completeAssets();
 		completeAssets();
 		this->imageUp = generateButtonImage(this->button, 0, width, height, this->color.value, this->text.value, this->font);
 		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() {
 void Panel::generateGraphics() {
 	int width = this->location.width();
 	int width = this->location.width();
 	int height = this->location.height();
 	int height = this->location.height();
+	if (width < 1) { width = 1; }
+	if (height < 1) { height = 1; }
 	if (!this->hasImages) {
 	if (!this->hasImages) {
 		completeAssets();
 		completeAssets();
 		this->background(width, height, this->color.value.red, this->color.value.green, this->color.value.blue)(this->imageBackground);
 		this->background(width, height, this->color.value.red, this->color.value.green, this->color.value.blue)(this->imageBackground);