summaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>2005-10-07 17:01:48 +0000
committerjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>2005-10-07 17:01:48 +0000
commit72231bd6a4e2e13f0a27696f257d1b5b195301d1 (patch)
tree681e44e7391bef780270f10d0a2b52d25cf777ff /libgfortran
parent2080a2d516328429d4ded709132cf1be305751ae (diff)
downloadgcc-72231bd6a4e2e13f0a27696f257d1b5b195301d1.tar.gz
2005-10-07 Jerry DeLisle <jvdelisle@verizon.net>
* io/transfer.c (write_block): Add test for end-of-file condition, removed from mem_alloc_w_at. (next_record_w): Clean up checks for NULL pointer returns from s_alloc_w. * io/unix.c (mem_alloc_w_at): Remove call to generate_error end-of-file. * io/write.c (write_float): Add checks for NULL pointer returns from write_block calls. (write_integer): Same. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@105092 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog9
-rw-r--r--libgfortran/io/transfer.c16
-rw-r--r--libgfortran/io/unix.c5
-rw-r--r--libgfortran/io/write.c10
4 files changed, 31 insertions, 9 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 16bef477a50..d0b2204f2b9 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,12 @@
+2005-10-07 Jerry DeLisle <jvdelisle@verizon.net>
+
+ * io/transfer.c (write_block): Add test for end-of-file condition,
+ removed from mem_alloc_w_at. (next_record_w): Clean up checks for
+ NULL pointer returns from s_alloc_w.
+ * io/unix.c (mem_alloc_w_at): Remove call to generate_error end-of-file.
+ * io/write.c (write_float): Add checks for NULL pointer returns from
+ write_block calls. (write_integer): Same.
+
2005-10-03 Jakub Jelinek <jakub@redhat.com>
* runtime/memory.c (allocate_size): Malloc 1 byte if size == 0.
diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c
index 06c5a98106e..3538766c576 100644
--- a/libgfortran/io/transfer.c
+++ b/libgfortran/io/transfer.c
@@ -304,6 +304,12 @@ write_block (int length)
current_unit->bytes_left -= (gfc_offset)length;
dest = salloc_w (current_unit->s, &length);
+
+ if (dest == NULL)
+ {
+ generate_error (ERROR_END, NULL);
+ return NULL;
+ }
if (ioparm.size != NULL)
*ioparm.size += length;
@@ -1559,16 +1565,20 @@ next_record_w (void)
{
bytes_left = (int) current_unit->bytes_left;
p = salloc_w (current_unit->s, &bytes_left);
- if (p != NULL)
+ if (p == NULL)
{
- memset(p, ' ', bytes_left);
- current_unit->bytes_left = current_unit->recl;
+ generate_error (ERROR_END, NULL);
+ return;
}
+ memset(p, ' ', bytes_left);
+ current_unit->bytes_left = current_unit->recl;
}
else
{
length = 1;
p = salloc_w (current_unit->s, &length);
+ if (p==NULL)
+ goto io_error;
}
}
else
diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c
index 4966726f830..28ac6ca66ae 100644
--- a/libgfortran/io/unix.c
+++ b/libgfortran/io/unix.c
@@ -630,10 +630,7 @@ mem_alloc_w_at (unix_stream * s, int *len, gfc_offset where)
return NULL;
if (m > s->file_length)
- {
- generate_error (ERROR_END, NULL);
- return NULL;
- }
+ return NULL;
s->logical_offset = m;
diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c
index b21399ff861..169810921c5 100644
--- a/libgfortran/io/write.c
+++ b/libgfortran/io/write.c
@@ -832,6 +832,8 @@ write_float (fnode *f, const char *source, int len)
if (nb == 0) nb = 4;
p = write_block (nb);
+ if (p == NULL)
+ return;
if (nb < 3)
{
memset (p, '*',nb);
@@ -903,6 +905,8 @@ write_float (fnode *f, const char *source, int len)
if (nb > 0)
{
p = write_block (nb);
+ if (p == NULL)
+ return;
memset (p, ' ', nb);
}
}
@@ -1277,6 +1281,8 @@ write_integer (const char *source, int length)
if(width < digits )
width = digits ;
p = write_block (width) ;
+ if (p == NULL)
+ return;
if (no_leading_blank)
{
memcpy (p, q, digits);
@@ -1284,8 +1290,8 @@ write_integer (const char *source, int length)
}
else
{
- memset(p ,' ', width - digits) ;
- memcpy (p + width - digits, q, digits);
+ memset(p ,' ', width - digits) ;
+ memcpy (p + width - digits, q, digits);
}
}