Permalink
Browse files

catch another malloc failure

  • Loading branch information...
1 parent 71f58a4 commit 2ca0e1fc81b1ec01294c3a0524ac8fbd27104e6b @dajobe committed Apr 10, 2012
Showing with 7 additions and 2 deletions.
  1. +7 −2 utils/roqet.c
View
@@ -1350,16 +1350,21 @@ main(int argc, char *argv[])
FILE *fh;
unsigned char* buffer;
+ buffer = (unsigned char*)malloc(FILE_READ_BUF_SIZE);
+ if(!buffer) {
+ rc = 1;
+ goto tidy_setup;
+ }
+
fh = fopen(filename, "r");
if(!fh) {
+ free(buffer);
fprintf(stderr, "%s: file '%s' open failed - %s",
program, filename, strerror(errno));
rc = 1;
goto tidy_setup;
}
- buffer = (unsigned char*)malloc(FILE_READ_BUF_SIZE);
-
while(!feof(fh)) {
size_t read_len;

0 comments on commit 2ca0e1f

Please sign in to comment.