fix: prevent segfault in case ispell does not provide any output
This commit is contained in:
@@ -17,7 +17,7 @@ zig build -Doptimize=ReleaseFast
|
|||||||
If you wish to install it into */usr/local/* you will have to provide the prefix argument:
|
If you wish to install it into */usr/local/* you will have to provide the prefix argument:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
sudo zig build install -p /usr/local/ -DoptimizeReleaseFast
|
sudo zig build install -p /usr/local/ -Doptimize=ReleaseFast
|
||||||
```
|
```
|
||||||
|
|
||||||
This was build using zig 0.12.0.dev but should work with the most recent version of zig.
|
This was build using zig 0.12.0.dev but should work with the most recent version of zig.
|
||||||
|
|||||||
@@ -85,6 +85,12 @@ pub fn main() !void {
|
|||||||
}
|
}
|
||||||
std.mem.copy(u8, content, output[start_idx .. output.len - 1]);
|
std.mem.copy(u8, content, output[start_idx .. output.len - 1]);
|
||||||
defer allocator.free(content);
|
defer allocator.free(content);
|
||||||
|
// prevent access to result if the ispell output has only a single line
|
||||||
|
if (output.len - start_idx > 0) {
|
||||||
|
try stdout_writer.print("{s}", .{word});
|
||||||
|
try bw.flush(); // don't forget to flush!
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (content[0] == '*' or content[0] == '+') {
|
if (content[0] == '*' or content[0] == '+') {
|
||||||
// given word was correct so just return the input as no replacement is necessary
|
// given word was correct so just return the input as no replacement is necessary
|
||||||
|
|||||||
Reference in New Issue
Block a user