all repos — mgba @ a1829a920d1b51bf0ff3f14e87260cd58c20e030

mGBA Game Boy Advance Emulator

GBA Config: Fix null ports from crashing
Jeffrey Pfau jeffrey@endrift.com
Mon, 17 Nov 2014 01:17:56 -0800
commit

a1829a920d1b51bf0ff3f14e87260cd58c20e030

parent

91762600448c41175b63a0a8e9424cfdd18c5f5a

1 files changed, 6 insertions(+), 2 deletions(-)

jump to
M src/gba/gba-config.csrc/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) {