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; }