2005-10-07 Jerry DeLisle <jvdelisle@verizon.net>
authorjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 7 Oct 2005 17:01:48 +0000 (17:01 +0000)
committerjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 7 Oct 2005 17:01:48 +0000 (17:01 +0000)
        * 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

libgfortran/ChangeLog
libgfortran/io/transfer.c
libgfortran/io/unix.c
libgfortran/io/write.c

index 16bef47..d0b2204 100644 (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.
index 06c5a98..3538766 100644 (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
index 4966726..28ac6ca 100644 (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;
 
index b21399f..1698109 100644 (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);
     }
 }