summaryrefslogtreecommitdiff
path: root/draw.c
diff options
context:
space:
mode:
Diffstat (limited to 'draw.c')
-rw-r--r--draw.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/draw.c b/draw.c
index 49fad1b..7e93e39 100644
--- a/draw.c
+++ b/draw.c
@@ -221,11 +221,16 @@ void get_arrow(FILE *fc){
char c;
int orig_x=x, orig_y=y, arrow_len;
static short *arrow = NULL;
+ short *tmp = NULL;
static int arrow_sz;
if (!arrow){
arrow_sz = 100;
arrow = malloc(arrow_sz * sizeof(short));
+ if (arrow == NULL){
+ fprintf(stderr, "Unable to allocate arrow");
+ cleanup(1);
+ }
}
arrow_len = 0;
dir = DIR_N;
@@ -242,7 +247,12 @@ void get_arrow(FILE *fc){
/* FIXME: if we are out of bound, do nothing? */
if (arrow_len == arrow_sz){
arrow_sz *=2;
- arrow = realloc(arrow, arrow_sz * sizeof(short));
+ tmp = realloc(arrow, arrow_sz * sizeof(short));
+ if (tmp == NULL){
+ fprintf(stderr, "Unable to reallocate arrow");
+ cleanup(1);
+ }
+ arrow = tmp;
}
if (dir != DIR_N){
arrow[arrow_len++] = dir;