Changeset - r25809:50a2cc464ada
[Not reviewed]
master
0 1 0
Rubidium - 3 years ago 2021-07-11 07:16:54
rubidium@openttd.org
Fix: ensure no more than the allowed number of NewGRFs are loaded from the configuration
1 file changed with 9 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/settings.cpp
Show inline comments
 
@@ -953,12 +953,13 @@ static GRFConfig *GRFLoadConfig(IniFile 
 
	IniItem *item;
 
	GRFConfig *first = nullptr;
 
	GRFConfig **curr = &first;
 

	
 
	if (group == nullptr) return nullptr;
 

	
 
	uint num_grfs = 0;
 
	for (item = group->item; item != nullptr; item = item->next) {
 
		GRFConfig *c = nullptr;
 

	
 
		uint8 grfid_buf[4], md5sum[16];
 
		const char *filename = item->name.c_str();
 
		bool has_grfid = false;
 
@@ -1027,14 +1028,20 @@ static GRFConfig *GRFLoadConfig(IniFile 
 
		}
 
		if (duplicate) {
 
			delete c;
 
			continue;
 
		}
 

	
 
		/* Mark file as static to avoid saving in savegame. */
 
		if (is_static) SetBit(c->flags, GCF_STATIC);
 
		if (is_static) {
 
			/* Mark file as static to avoid saving in savegame. */
 
			SetBit(c->flags, GCF_STATIC);
 
		} else if (++num_grfs > NETWORK_MAX_GRF_COUNT) {
 
			/* Check we will not load more non-static NewGRFs than allowed. This could trigger issues for game servers. */
 
			ShowErrorMessage(STR_CONFIG_ERROR, STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED, WL_CRITICAL);
 
			break;
 
		}
 

	
 
		/* Add item to list */
 
		*curr = c;
 
		curr = &c->next;
 
	}
 

	
0 comments (0 inline, 0 general)