aboutsummaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorFrancois-Xavier Coudert <fxcoudert@gcc.gnu.org>2007-05-04 15:14:07 +0000
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>2007-05-04 15:14:07 +0000
commite50443368c22ea4a2ec4e6585154b13cae31dc09 (patch)
tree6721ce468249b54015ad164eb75433afc4bde44c /libgfortran
parentc531371e87f6220c177a57d9a34e065cb3dc701d (diff)
downloadgcc-e50443368c22ea4a2ec4e6585154b13cae31dc09.zip
gcc-e50443368c22ea4a2ec4e6585154b13cae31dc09.tar.gz
gcc-e50443368c22ea4a2ec4e6585154b13cae31dc09.tar.bz2
re PR libfortran/31210 (I/O of string with (non-constant) zero length)
PR libfortran/31210 * io/transfer.c (transfer_character): Avoid passing a NULL pointer as source to the transfer routines, if the string length is zero. From-SVN: r124428
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog7
-rw-r--r--libgfortran/io/transfer.c9
2 files changed, 16 insertions, 0 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 409c20d..52f1506 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,10 @@
+2007-05-04 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
+
+ PR libfortran/31210
+ * io/transfer.c (transfer_character): Avoid passing a NULL
+ pointer as source to the transfer routines, if the string length
+ is zero.
+
2007-04-28 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libfortran/31501
diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c
index 13bb272..1e90e83 100644
--- a/libgfortran/io/transfer.c
+++ b/libgfortran/io/transfer.c
@@ -1401,8 +1401,17 @@ transfer_logical (st_parameter_dt *dtp, void *p, int kind)
void
transfer_character (st_parameter_dt *dtp, void *p, int len)
{
+ static char *empty_string[0];
+
if ((dtp->common.flags & IOPARM_LIBRETURN_MASK) != IOPARM_LIBRETURN_OK)
return;
+
+ /* Strings of zero length can have p == NULL, which confuses the
+ transfer routines into thinking we need more data elements. To avoid
+ this, we give them a nice pointer. */
+ if (len == 0 && p == NULL)
+ p = empty_string;
+
/* Currently we support only 1 byte chars, and the library is a bit
confused of character kind vs. length, so we kludge it by setting
kind = length. */