mirror of
https://github.com/archlinuxarm/PKGBUILDs.git
synced 2025-02-16 23:57:11 +00:00
53 lines
1.7 KiB
Diff
53 lines
1.7 KiB
Diff
From aa4b6727e65471f305a337400ebc36b3d74d442a Mon Sep 17 00:00:00 2001
|
|
From: Fabian Greffrath <fabian+debian@greffrath.com>
|
|
Date: Tue, 28 Oct 2014 06:27:33 +0100
|
|
Subject: [PATCH 3/3] setup: dynamically set size of iwad_labels array
|
|
|
|
With the addition of the Freedoom IWADs, the number of IWADs supported
|
|
by chocolate-doom has been raised to 10. However, the iwad_labels[]
|
|
array only holds place for up to 8 pointers. Incidently, I have all 10
|
|
IWADs installed and trying to warp into a game from
|
|
chocolate-doom-setup leads to an out-of-bounds access of this array
|
|
and so the application crashes with a segmentation fault.
|
|
|
|
Instead of increasing the array size to 10, which will bite us next
|
|
time, I decided to set its size dynamically as soon as the number of
|
|
IWADs of known.
|
|
---
|
|
src/setup/multiplayer.c | 10 ++++++++--
|
|
1 file changed, 8 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/src/setup/multiplayer.c b/src/setup/multiplayer.c
|
|
index d833a49..2aaae9a 100644
|
|
--- a/src/setup/multiplayer.c
|
|
+++ b/src/setup/multiplayer.c
|
|
@@ -55,7 +55,7 @@ static const iwad_t fallback_iwads[] = {
|
|
// Array of IWADs found to be installed
|
|
|
|
static const iwad_t **found_iwads;
|
|
-static char *iwad_labels[8];
|
|
+static char **iwad_labels;
|
|
|
|
// Index of the currently selected IWAD
|
|
|
|
@@ -559,10 +559,16 @@ static txt_widget_t *IWADSelector(void)
|
|
|
|
for (i=0; found_iwads[i] != NULL; ++i)
|
|
{
|
|
- iwad_labels[i] = found_iwads[i]->description;
|
|
++num_iwads;
|
|
}
|
|
|
|
+ iwad_labels = malloc(sizeof(*iwad_labels) * num_iwads);
|
|
+
|
|
+ for (i=0; i < num_iwads; ++i)
|
|
+ {
|
|
+ iwad_labels[i] = found_iwads[i]->description;
|
|
+ }
|
|
+
|
|
// If no IWADs are found, provide Doom 2 as an option, but
|
|
// we're probably screwed.
|
|
|
|
--
|
|
2.3.5
|
|
|