summaryrefslogtreecommitdiff
path: root/rts/RtsFlags.c
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-07-26 10:32:25 -0400
committerBen Gamari <ben@smart-cactus.org>2019-07-26 10:34:04 -0400
commitdde76af0af6ef75e2593d9135f432170b1c841dc (patch)
tree57cce4928fa40a44d76c3995c4cc440e4649cc19 /rts/RtsFlags.c
parentb9c99df1a4cdd23bcd26db7ae6ee7ee6464d654e (diff)
downloadhaskell-wip/T16993.tar.gz
rts: Always truncate output fileswip/T16993
Previously there were numerous places in the RTS where we would fopen with the "w" flag string. This is wrong as it will not truncate the file. Consequently if we write less data than the previous length of the file we will leave garbage at its end. Fixes #16993.
Diffstat (limited to 'rts/RtsFlags.c')
-rw-r--r--rts/RtsFlags.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/rts/RtsFlags.c b/rts/RtsFlags.c
index 8d9b052bc7..5cdf08e9a5 100644
--- a/rts/RtsFlags.c
+++ b/rts/RtsFlags.c
@@ -1745,7 +1745,7 @@ openStatsFile (char *filename, // filename, or NULL
f = NULL; /* NULL means use debugBelch */
} else {
if (*filename != '\0') { /* stats file specified */
- f = __rts_fopen (filename,"w");
+ f = __rts_fopen (filename,"w+");
} else {
if (filename_fmt == NULL) {
errorBelch("Invalid stats filename format (NULL)\n");
@@ -1755,7 +1755,7 @@ openStatsFile (char *filename, // filename, or NULL
char stats_filename[STATS_FILENAME_MAXLEN];
snprintf(stats_filename, STATS_FILENAME_MAXLEN, filename_fmt,
prog_name);
- f = __rts_fopen (stats_filename,"w");
+ f = __rts_fopen (stats_filename,"w+");
}
if (f == NULL) {
errorBelch("Can't open stats file %s\n", filename);