diff options
| author | Zac Pierson <zacpiersonhehe@gmail.com> | 2017-03-21 16:00:11 -0500 |
|---|---|---|
| committer | Zac Pierson <zacpiersonhehe@gmail.com> | 2017-03-21 16:00:11 -0500 |
| commit | e935f8e2ffc19294573025287a08dcbe9137e282 (patch) | |
| tree | db9499bb36da04543bdf2866afd9717611362061 | |
| parent | 690c6828476b0714464adf4813fde37a841104d7 (diff) | |
Fixed os_linux and os_x read_entire_file function not null-terminating data.
| -rw-r--r-- | core/os_linux.odin | 3 | ||||
| -rw-r--r-- | core/os_x.odin | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/core/os_linux.odin b/core/os_linux.odin index 0fd8287ce..52b9dad51 100644 --- a/core/os_linux.odin +++ b/core/os_linux.odin @@ -146,13 +146,14 @@ read_entire_file :: proc(name: string) -> ([]byte, bool) { // We have a file size! - data := new_slice(u8, size); + data := new_slice(u8, size+1); if data.data == nil { fmt.println("Failed to allocate file buffer."); return nil, false; } read(handle, data); + data[size] = 0; return data, true; } diff --git a/core/os_x.odin b/core/os_x.odin index c665b533d..6133bce7c 100644 --- a/core/os_x.odin +++ b/core/os_x.odin @@ -150,13 +150,14 @@ read_entire_file :: proc(name: string) -> ([]byte, bool) { // We have a file size! - data := new_slice(u8, size); + data := new_slice(u8, size+1); if data.data == nil { fmt.println("Failed to allocate file buffer."); return nil, false; } read(handle, data); + data[size] = 0; return data, true; } |