Skip to content

Commit 78f60d7

Browse files
committed
Ensure null terminator is set
I'm not 100% sure of this code.
1 parent 2950bc6 commit 78f60d7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

runtime/FileUtilities.cake

+2-1
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,9 @@
122122
(fseek in-file 0 SEEK_END)
123123
(var file-size size_t (ftell in-file))
124124
(rewind in-file)
125-
(var-cast-to out-buffer (* char) (malloc file-size))
125+
(var-cast-to out-buffer (* char) (malloc (+ 1 file-size)))
126126
(fread out-buffer file-size 1 in-file)
127+
(set (at file-size contents-buffer) 0)
127128
(return out-buffer))
128129
129130
(defun write-string (out-file (* FILE) out-string (* (const char)))

0 commit comments

Comments
 (0)