summaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2007-05-28 16:39:35 +0000
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2007-05-28 16:39:35 +0000
commitcea79fbe3c3e9bde214a3136180b86b3a6c21022 (patch)
treeac651ce2ab48b34d6f5845e8ef6a4638989a0d77 /libgfortran
parent12d06f67b8843b1edc161ef139cd5e783e3b4750 (diff)
downloadgcc-cea79fbe3c3e9bde214a3136180b86b3a6c21022.tar.gz
2007-05-28 Tobias Burnus <burnus@net-b.de>
PR fortran/32124 * runtime/memory.c (allocate_size): Use ERROR_ALLOCATION. (allocate,allocate64): Use stat variable if present. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@125133 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog6
-rw-r--r--libgfortran/runtime/memory.c26
2 files changed, 27 insertions, 5 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 246eee50289..f0b012b38fb 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,9 @@
+2007-05-28 Tobias Burnus <burnus@net-b.de>
+
+ PR fortran/32124
+ * runtime/memory.c (allocate_size): Use ERROR_ALLOCATION.
+ (allocate,allocate64): Use stat variable if present.
+
2007-05-27 Janne Blomqvist <jb@gcc.gnu.org>
* runtime/string.c (compare0): Use gfc_charlen_type instead of
diff --git a/libgfortran/runtime/memory.c b/libgfortran/runtime/memory.c
index fe76675c9ad..53643dc7ec6 100644
--- a/libgfortran/runtime/memory.c
+++ b/libgfortran/runtime/memory.c
@@ -144,7 +144,7 @@ allocate_size (size_t size, GFC_INTEGER_4 * stat)
{
if (stat)
{
- *stat = 1;
+ *stat = ERROR_ALLOCATION;
return newmem;
}
else
@@ -164,8 +164,16 @@ void *
allocate (GFC_INTEGER_4 size, GFC_INTEGER_4 * stat)
{
if (size < 0)
- runtime_error ("Attempt to allocate negative amount of memory. "
- "Possible integer overflow");
+ {
+ if (stat)
+ {
+ *stat = ERROR_ALLOCATION;
+ return NULL;
+ }
+ else
+ runtime_error ("Attempt to allocate negative amount of memory. "
+ "Possible integer overflow");
+ }
return allocate_size ((size_t) size, stat);
}
@@ -177,8 +185,16 @@ void *
allocate64 (GFC_INTEGER_8 size, GFC_INTEGER_4 * stat)
{
if (size < 0)
- runtime_error ("ALLOCATE64: Attempt to allocate negative amount of "
- "memory. Possible integer overflow");
+ {
+ if (stat)
+ {
+ *stat = ERROR_ALLOCATION;
+ return NULL;
+ }
+ else
+ runtime_error ("ALLOCATE64: Attempt to allocate negative amount of "
+ "memory. Possible integer overflow");
+ }
return allocate_size ((size_t) size, stat);
}