fixed out of bounds write in load_tilemap
parent
34593e0701
commit
89cc8b9969
|
@ -55,8 +55,7 @@ int load_tilemap(const char* file) {
|
||||||
case ' ':
|
case ' ':
|
||||||
case '\n':
|
case '\n':
|
||||||
case '\t':
|
case '\t':
|
||||||
// ignore
|
break; // ignore
|
||||||
break;
|
|
||||||
case EOF:
|
case EOF:
|
||||||
case ',':
|
case ',':
|
||||||
*writer = '\0';
|
*writer = '\0';
|
||||||
|
@ -65,6 +64,7 @@ int load_tilemap(const char* file) {
|
||||||
} else if(entries == 1) {
|
} else if(entries == 1) {
|
||||||
g_tilemap.height = atoi(buf);
|
g_tilemap.height = atoi(buf);
|
||||||
} else {
|
} else {
|
||||||
|
if(entries-2 >= TILEMAP_MAX_SIZE) goto end_while;
|
||||||
tile->value = (short)atoi(buf);
|
tile->value = (short)atoi(buf);
|
||||||
++tile;
|
++tile;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "vector"
|
#include "vector"
|
||||||
#include "corelib/render.h"
|
#include "corelib/render.h"
|
||||||
|
|
||||||
#define TILEMAP_MAX_SIZE 128*128
|
#define TILEMAP_MAX_SIZE 16384
|
||||||
|
|
||||||
typedef struct tile_t {
|
typedef struct tile_t {
|
||||||
short value;
|
short value;
|
||||||
|
|
Loading…
Reference in New Issue