+2015-09-12 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
+
+ PR libfortran/67527
+ PR libfortran/67535
+ PR libfortran/67536
+ * io/io.h: Use unsigned values for 31-bit left shifts.
+ * io/unix.c (buf_read): Do not call memcpy() with NULL pointer arg.
+ * io/write.c (nml_write_obj): Likewise.
+
2015-09-05 Janne Blomqvist <jb@gcc.gnu.org>
PR fortran/53379
#define IOPARM_INQUIRE_HAS_WRITE (1 << 28)
#define IOPARM_INQUIRE_HAS_READWRITE (1 << 29)
#define IOPARM_INQUIRE_HAS_CONVERT (1 << 30)
-#define IOPARM_INQUIRE_HAS_FLAGS2 (1 << 31)
+#define IOPARM_INQUIRE_HAS_FLAGS2 (1u << 31)
#define IOPARM_INQUIRE_HAS_ASYNCHRONOUS (1 << 0)
#define IOPARM_INQUIRE_HAS_DECIMAL (1 << 1)
#define IOPARM_DT_HAS_SIGN (1 << 24)
#define IOPARM_DT_HAS_F2003 (1 << 25)
/* Internal use bit. */
-#define IOPARM_DT_IONML_SET (1 << 31)
+#define IOPARM_DT_IONML_SET (1u << 31)
typedef struct st_parameter_dt
/* Is the data we want in the buffer? */
if (s->logical_offset + nbyte <= s->buffer_offset + s->active
&& s->buffer_offset <= s->logical_offset)
- memcpy (buf, s->buffer + (s->logical_offset - s->buffer_offset), nbyte);
+ {
+ /* When nbyte == 0, buf can be NULL which would lead to undefined
+ behavior if we called memcpy(). */
+ if (nbyte != 0)
+ memcpy (buf, s->buffer + (s->logical_offset - s->buffer_offset),
+ nbyte);
+ }
else
{
/* First copy the active bytes if applicable, then read the rest
+ strlen (obj->var_name) + obj->var_rank * NML_DIGITS + 1;
ext_name = xmalloc (ext_name_len);
- memcpy (ext_name, base_name, base_name_len);
+ if (base_name)
+ memcpy (ext_name, base_name, base_name_len);
clen = strlen (obj->var_name + base_var_name_len);
memcpy (ext_name + base_name_len,
obj->var_name + base_var_name_len, clen);