aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/msgfile.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/msgfile.c b/src/msgfile.c
index a2901de..ac90e41 100644
--- a/src/msgfile.c
+++ b/src/msgfile.c
@@ -592,13 +592,19 @@ static void msgfile_read2(t_msgfile *x, t_symbol *filename, t_symbol *format)
break;
}
- if ((length = lseek(fd, 0, SEEK_END)) < 0 || lseek(fd, 0,SEEK_SET) < 0
- || !(readbuf = t_getbytes(length))) {
+ if ((length = lseek(fd, 0, SEEK_END)) < 0 || lseek(fd, 0,SEEK_SET) < 0) {
pd_error(x, "msgfile_read: unable to lseek %s", filnam);
close(fd);
return;
}
+ if (!(readbuf = t_getbytes(length))) {
+ pd_error(x, "msgfile_read: could not reserve %d bytes to read into", length);
+ close(fd);
+ return;
+ }
+
+
/* read */
if ((readlength = read(fd, readbuf, length)) < length) {
pd_error(x, "msgfile_read: unable to read %s", filnam);