Skip to content

Commit

Permalink
Use O_TRUNC for files opened with "w"
Browse files Browse the repository at this point in the history
  • Loading branch information
waschik committed Feb 19, 2023
1 parent fa815b5 commit 71163b6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion iolib.go
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ func ioOpenFile(L *LState) int {
mode = os.O_RDONLY
writable = false
case "w", "wb":
mode = os.O_WRONLY | os.O_CREATE
mode = os.O_WRONLY | os.O_TRUNC | os.O_CREATE
readable = false
case "a", "ab":
mode = os.O_WRONLY | os.O_APPEND | os.O_CREATE
Expand Down

0 comments on commit 71163b6

Please sign in to comment.