Handle map path being too long
This commit is contained in:
parent
296975caa1
commit
eaf8df0fb1
11
app/main.c
11
app/main.c
@ -7,6 +7,7 @@
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <string.h>
|
||||
|
||||
#define TILESIZE 32
|
||||
#define WINWIDTH 30
|
||||
@ -26,6 +27,8 @@ static unsigned map[MAPWIDTH][MAPHEIGHT];
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char path[MAX_PATH_LEN];
|
||||
|
||||
if (2 != argc) {
|
||||
fprintf(stderr, "Usage: %s ASSETS-DIR\n", argv[0]);
|
||||
return 1;
|
||||
@ -42,10 +45,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
xmlDocPtr doc;
|
||||
xmlNodePtr node;
|
||||
char mappath[MAX_PATH_LEN];
|
||||
strncpy(mappath, argv[1], MAX_PATH_LEN);
|
||||
strncat(mappath, MAP_ASSET, MAX_PATH_LEN);
|
||||
doc = xmlParseFile(mappath);
|
||||
assert(strlen(argv[1]) + strlen(MAP_ASSET) < MAX_PATH_LEN);
|
||||
strcpy(path, argv[1]);
|
||||
strcat(path, MAP_ASSET);
|
||||
doc = xmlParseFile(path);
|
||||
assert(NULL != doc);
|
||||
node = xmlDocGetRootElement(doc);
|
||||
assert(0 == xmlStrcmp(node->name, (const xmlChar *)"map"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user