Skip to content

Commit 71163b6

Browse files
committed
Use O_TRUNC for files opened with "w"
1 parent fa815b5 commit 71163b6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

iolib.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ func ioOpenFile(L *LState) int {
629629
mode = os.O_RDONLY
630630
writable = false
631631
case "w", "wb":
632-
mode = os.O_WRONLY | os.O_CREATE
632+
mode = os.O_WRONLY | os.O_TRUNC | os.O_CREATE
633633
readable = false
634634
case "a", "ab":
635635
mode = os.O_WRONLY | os.O_APPEND | os.O_CREATE

0 commit comments

Comments
 (0)