==18502== Invalid write of size 8 ==18502== at 0x48E9E0: SV_MapcycleAdd (sv_main.c:858) ==18502== by 0x48EBAD: SV_ParseMapcycle (sv_main.c:904) ==18502== by 0x48F41B: SV_Init (sv_main.c:1133) ==18502== by 0x47A5D7: Qcommon_Init (common.c:1552) ==18502== by 0x49D6F6: main (sys_linux.c:538) ==18502== Address 0xF15F6D0 is 0 bytes after a block of size 8 alloc'd ==18502== at 0xE43FB4B: malloc (in /usr/lib64/valgrind/amd64-linux/vgpreload_memcheck.so) ==18502== by 0x48E896: SV_MapcycleAdd (sv_main.c:844) ==18502== by 0x48EBAD: SV_ParseMapcycle (sv_main.c:904) ==18502== by 0x48F41B: SV_Init (sv_main.c:1133) ==18502== by 0x47A5D7: Qcommon_Init (common.c:1552) ==18502== by 0x49D6F6: main (sys_linux.c:538) ==18502== ==18502== Invalid read of size 8 ==18502== at 0x48EA10: SV_MapcycleAdd (sv_main.c:859) ==18502== by 0x48EBAD: SV_ParseMapcycle (sv_main.c:904) ==18502== by 0x48F41B: SV_Init (sv_main.c:1133) ==18502== by 0x47A5D7: Qcommon_Init (common.c:1552) ==18502== by 0x49D6F6: main (sys_linux.c:538) ==18502== Address 0xF15F6D0 is 0 bytes after a block of size 8 alloc'd ==18502== at 0xE43FB4B: malloc (in /usr/lib64/valgrind/amd64-linux/vgpreload_memcheck.so) ==18502== by 0x48E896: SV_MapcycleAdd (sv_main.c:844) ==18502== by 0x48EBAD: SV_ParseMapcycle (sv_main.c:904) ==18502== by 0x48F41B: SV_Init (sv_main.c:1133) ==18502== by 0x47A5D7: Qcommon_Init (common.c:1552) ==18502== by 0x49D6F6: main (sys_linux.c:538) related code: extern void SV_MapcycleAdd (const char* mapName, const char* gameType) { mapcycle_t *mapcycle; if (!mapcycleList) { mapcycleList = malloc(sizeof(mapcycleList)); mapcycle = mapcycleList; /* first one */ } else { /* go the the last entry */ mapcycle = mapcycleList; while (mapcycle->next) mapcycle = mapcycle->next; mapcycle->next = malloc(sizeof(mapcycleList)); mapcycle = mapcycle->next; } assert(mapName); mapcycle->map = (char*)malloc(sizeof(char) * (strlen(mapName) + 1)); Q_strncpyz(mapcycle->map, mapName, strlen(mapName) + 1); assert(gameType); mapcycle->type = (char*)malloc(sizeof(char) * (strlen(gameType) + 1)); Q_strncpyz(mapcycle->type, gameType, strlen(gameType) + 1); Com_DPrintf("mapcycle add: '%s' type '%s'\n", mapcycle->map, mapcycle->type); mapcycle->next = NULL; mapcycleCount++; }