GBA Config: Fix null ports from crashing

This commit is contained in:
Jeffrey Pfau 2014-11-17 01:17:56 -08:00
parent 9176260044
commit a1829a920d
1 changed files with 6 additions and 2 deletions

View File

@ -90,8 +90,12 @@ static bool _lookupFloatValue(const struct GBAConfig* config, const char* key, f
void GBAConfigInit(struct GBAConfig* config, const char* port) {
ConfigurationInit(&config->configTable);
ConfigurationInit(&config->defaultsTable);
config->port = malloc(strlen("ports.") + strlen(port) + 1);
snprintf(config->port, strlen("ports.") + strlen(port) + 1, "ports.%s", port);
if (port) {
config->port = malloc(strlen("ports.") + strlen(port) + 1);
snprintf(config->port, strlen("ports.") + strlen(port) + 1, "ports.%s", port);
} else {
config->port = 0;
}
}
void GBAConfigDeinit(struct GBAConfig* config) {