]> rtime.felk.cvut.cz Git - l4.git/blobdiff - l4/pkg/libgfortran/lib/contrib/intrinsics/system.c
Update
[l4.git] / l4 / pkg / libgfortran / lib / contrib / intrinsics / system.c
index 5bc083a1ad093b26abb29ad29e56991fa541c92b..f291030f0f231356cdca408b52c2c81741991741 100644 (file)
@@ -1,5 +1,5 @@
 /* Implementation of the SYSTEM intrinsic.
-   Copyright (C) 2004, 2007, 2009, 2011 Free Software Foundation, Inc.
+   Copyright (C) 2004-2015 Free Software Foundation, Inc.
    Contributed by Tobias Schlüter.
 
 This file is part of the GNU Fortran runtime library (libgfortran).
@@ -34,16 +34,14 @@ iexport_proto(system_sub);
 void
 system_sub (const char *fcmd, GFC_INTEGER_4 *status, gfc_charlen_type cmd_len)
 {
-  char cmd[cmd_len + 1];
+  char *cmd = fc_strdup (fcmd, cmd_len);
   int stat;
 
   /* Flush all I/O units before executing the command.  */
   flush_all_units();
 
-  memcpy (cmd, fcmd, cmd_len);
-  cmd[cmd_len] = '\0';
-
   stat = system (cmd);
+  free (cmd);
   if (status)
     *status = stat;
 }