From 05bff5cefb4b9c1b74a6f2ae54b2b06da66f5f39 Mon Sep 17 00:00:00 2001 From: Max Regan Date: Tue, 23 May 2017 22:12:22 -0700 Subject: [PATCH] gbasm: truncate file at end of output When overwriting an old output file, this will delete the extra data if the new output is shorter than the old output. --- src/apps/gbasm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apps/gbasm.c b/src/apps/gbasm.c index 922d6de..1788d10 100644 --- a/src/apps/gbasm.c +++ b/src/apps/gbasm.c @@ -39,7 +39,7 @@ int main(int argc, char **argv) close(out_fd); } - out_fd = open(optarg, O_WRONLY | O_CREAT); + out_fd = open(optarg, O_WRONLY | O_CREAT | O_TRUNC); if (out_fd < 0) { fprintf(stderr, "failed to open output file %s\n", optarg); exit(1);