From c1dcf22feae4bacfc32dfa24e8d73fa45cb6f813 Mon Sep 17 00:00:00 2001
From: Rob Swindell <rob@synchro.net>
Date: Tue, 29 Dec 2020 16:34:07 -0800
Subject: [PATCH] Fix error: "Number of chat chatacts exceeds max_chatacts (0)"

If the CTRL/MAXS.CFG is missing the item of interest, default to the
absolute maximum possible "maximum".

Allocate the chatact array.
---
 SRC/SCFG/SCFG.C | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/SRC/SCFG/SCFG.C b/SRC/SCFG/SCFG.C
index a416de7..be89b1f 100644
--- a/SRC/SCFG/SCFG.C
+++ b/SRC/SCFG/SCFG.C
@@ -158,12 +158,12 @@ bail(1);
 
 void read_max(uint *max, uint MAX, FILE *stream)
 {
-	char str[256];
+	char str[256] = "";
 	int i;
 
 readline(&i,str,5,stream);
 (*max)=atoi(str);
-if((*max)>MAX) (*max)=MAX;
+if((*max) < 1 || (*max)>MAX) (*max)=MAX;
 }
 
 int main(int argc, char **argv)
@@ -247,6 +247,7 @@ read_max(&max_phubs,MAX_PHUBS,instream);
 read_max(&max_qhubs,MAX_QHUBS,instream);
 read_max(&max_qsubs,MAX_QSUBS,instream);
 read_max(&max_results,MAX_RESULTS,instream);
+read_max(&max_chatacts,MAX_CHATACTS,instream);
 fclose(instream);
 
 if((node_path=(char **)MALLOC(sizeof(char *)*MAX_NODES))==NULL)
@@ -320,6 +321,9 @@ if(max_chans)
 	if((chan=(chan_t **)MALLOC(sizeof(chan_t *)*max_chans))==NULL)
 		allocfail(sizeof(chan_t *)*max_chans);
 
+if(max_chatacts)
+	if((chatact=(chatact_t **)MALLOC(sizeof(chatact_t *)*max_chatacts))==NULL)
+		allocfail(sizeof(chatact_t *)*max_chatacts);
 
 txt.reading="\r\nReading %s...";
 txt.readit="\rRead %s       ";
-- 
GitLab