Maelstrom: Fixed memory corruption in dialog code.

From e4ddd3b839a059a8558cd0578e157a257bd27439 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sat, 22 Oct 2011 03:57:33 -0400
Subject: [PATCH] Fixed memory corruption in dialog code.

---
 dialog.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/dialog.h b/dialog.h
index 38c6a7d4..10c6e67e 100644
--- a/dialog.h
+++ b/dialog.h
@@ -135,7 +135,7 @@ class Mac_Button : public Mac_Dialog {
 		Mac_Dialog::Map(Xoff, Yoff, screen);
 
 		/* Create the button images */
-		int pitch = (Width+3)&3;
+		int pitch = (Width+3)&~3;
 		Uint8 *image_bits = new Uint8[Height*pitch];
 		Bevel_Button(image_bits, pitch);
 		button[0] = Screen->LoadImage(Width, Height, image_bits);
@@ -143,6 +143,9 @@ class Mac_Button : public Mac_Dialog {
 		button[1] = Screen->LoadImage(Width, Height, image_bits);
 		delete[] image_bits;
 
+		labelX = X + (Width - Screen->GetImageWidth(label))/2;
+		labelY = Y + (Height - Screen->GetImageHeight(label))/2;
+
 		/* Set up the button sensitivity */
 		sensitive.x = X;
 		sensitive.y  = Y;
@@ -151,6 +154,7 @@ class Mac_Button : public Mac_Dialog {
 	}
 	virtual void Show(void) {
 		Screen->QueueBlit(X, Y, button[0], NOCLIP);
+		Screen->QueueBlit(labelX, labelY, label, NOCLIP);
 	}
 
 	virtual void HandleButtonPress(int x, int y, int button, int *doneflag) {
@@ -160,6 +164,7 @@ class Mac_Button : public Mac_Dialog {
 
 protected:
 	int Width, Height;
+	int labelX, labelY;
 	FontServ *Fontserv;
 	SDL_Texture *label;
 	SDL_Texture *button[2];