mirror of
https://github.com/odin-lang/Odin.git
synced 2025-12-28 17:04:34 +00:00
Fixed os_linux and os_x read_entire_file function not null-terminating data.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user