summaryrefslogtreecommitdiffstats
path: root/src/extras/frontendoption.cpp
diff options
context:
space:
mode:
authorerorcun <erayorcunus@gmail.com>2020-07-01 14:28:43 +0200
committerGitHub <noreply@github.com>2020-07-01 14:28:43 +0200
commiteda50bc32bafaea788def2f00f4ac036329dd46c (patch)
treeef0200e6f8ce0e24ef52ccb8b70c32c1cbdb35f3 /src/extras/frontendoption.cpp
parentlittle fix (diff)
downloadre3-eda50bc32bafaea788def2f00f4ac036329dd46c.tar
re3-eda50bc32bafaea788def2f00f4ac036329dd46c.tar.gz
re3-eda50bc32bafaea788def2f00f4ac036329dd46c.tar.bz2
re3-eda50bc32bafaea788def2f00f4ac036329dd46c.tar.lz
re3-eda50bc32bafaea788def2f00f4ac036329dd46c.tar.xz
re3-eda50bc32bafaea788def2f00f4ac036329dd46c.tar.zst
re3-eda50bc32bafaea788def2f00f4ac036329dd46c.zip
Diffstat (limited to '')
-rw-r--r--src/extras/frontendoption.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/extras/frontendoption.cpp b/src/extras/frontendoption.cpp
index 6ab2801c..bfeca848 100644
--- a/src/extras/frontendoption.cpp
+++ b/src/extras/frontendoption.cpp
@@ -68,9 +68,11 @@ int8 RegisterNewOption(int screen)
{
numCustomFrontendOptions++;
if (numCustomFrontendOptions == 1)
- customFrontendOptions = (FrontendOption*)malloc(numCustomFrontendOptions * sizeof(FrontendOption));
- else
- customFrontendOptions = (FrontendOption*)realloc(customFrontendOptions, numCustomFrontendOptions * sizeof(FrontendOption));
+ customFrontendOptions = (FrontendOption*)malloc(5 * sizeof(FrontendOption));
+ else if (numCustomFrontendOptions % 5 == 1)
+ customFrontendOptions = (FrontendOption*)realloc(customFrontendOptions, (numCustomFrontendOptions + 4) * sizeof(FrontendOption));
+
+ assert(customFrontendOptions != nil && "Custom frontend options can't be allocated");
uint8 nth = GetNumberOfMenuOptions(screen);
if (optionCursor < 0) {