transfer.c (write_block): Add test for end-of-file condition, removed from mem_alloc_w_at.

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.

From-SVN: r105092
This commit is contained in:
Jerry DeLisle 2005-10-07 17:01:48 +00:00 committed by Jerry DeLisle
parent 3e352c00e1
commit aed6ee2453
4 changed files with 31 additions and 9 deletions

View File

@ -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.

View File

@ -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

View File

@ -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;

View File

@ -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);
}
}