From 44d0f3cfa2e5c7d4d99e689560caa34eae5c4683 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sun, 29 Dec 2013 20:11:05 +0200 Subject: [PATCH 1/2] Handle return value of read() call. --- py/lexerunix.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/py/lexerunix.c b/py/lexerunix.c index ac07781b5a..80daf6009a 100644 --- a/py/lexerunix.c +++ b/py/lexerunix.c @@ -48,8 +48,13 @@ mp_lexer_t *mp_lexer_new_from_file(const char *filename) { uint size = lseek(fd, 0, SEEK_END); lseek(fd, 0, SEEK_SET); char *data = m_new(char, size); - read(fd, data, size); + int read_size = read(fd, data, size); close(fd); + if (read_size != size) { + printf("error reading file %s\n", filename); + m_free(data); + return NULL; + } return mp_lexer_new_from_str_len(filename, data, size, true); } From 729fd12fbf003d4eb61a8429e06889ea66688939 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sun, 29 Dec 2013 20:12:33 +0200 Subject: [PATCH 2/2] Don't error out if build/ directory already exists. --- unix/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unix/Makefile b/unix/Makefile index 441804e509..91e26e5247 100644 --- a/unix/Makefile +++ b/unix/Makefile @@ -65,7 +65,7 @@ $(PROG): $(BUILD) $(OBJ) size $(PROG) $(BUILD): - mkdir $@ + mkdir -p $@ $(BUILD)/%.o: %.c $(CC) $(CFLAGS) -c -o $@ $<