diff options
author | Joseph Herlant <aerostitch@users.noreply.github.com> | 2018-03-30 23:26:56 -0700 |
---|---|---|
committer | jkoan <jkoan@users.noreply.github.com> | 2018-03-31 08:26:56 +0200 |
commit | ca8fc7ff2ac5f5bc3d32705e91e04c4c65f78448 (patch) | |
tree | 556089a3d417f6e52222a2e3766948bce9239c0d | |
parent | 4bb880107f27a87cdc9b16cc79a839d08ee2d46b (diff) | |
download | navit-ca8fc7ff2ac5f5bc3d32705e91e04c4c65f78448.tar.gz |
maptool: prevent issues when realloc fails (#419)
-rw-r--r-- | navit/maptool/tile.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/navit/maptool/tile.c b/navit/maptool/tile.c index 76469376c..cb6a78090 100644 --- a/navit/maptool/tile.c +++ b/navit/maptool/tile.c @@ -513,9 +513,14 @@ load_tilesdir(FILE *in) #if 0 printf("subtile '%s'\n",subtile); #endif - th=realloc(th, sizeof(struct tile_head)+(th->num_subtiles+1)*sizeof(char*)); - *th_get_subtile( th, th->num_subtiles ) = string_hash_lookup(subtile); - th->num_subtiles++; + struct tile_head *th_tmp=realloc(th, sizeof(struct tile_head)+(th->num_subtiles+1)*sizeof(char*)); + if (th_tmp == NULL) { + printf("Memory allocation failure, unable to load subtiles\n"); + } else { + th = th_tmp; + *th_get_subtile( th, th->num_subtiles ) = string_hash_lookup(subtile); + th->num_subtiles++; + } } *last=th; last=&th->next; |