GBA Config: Fix null ports from crashing
Jeffrey Pfau jeffrey@endrift.com
Mon, 17 Nov 2014 01:17:56 -0800
1 files changed,
6 insertions(+),
2 deletions(-)
jump to
M
src/gba/gba-config.c
→
src/gba/gba-config.c
@@ -90,8 +90,12 @@
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) {