aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--spec/ruby/optional/capi/ext/string_spec.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/spec/ruby/optional/capi/ext/string_spec.c b/spec/ruby/optional/capi/ext/string_spec.c
index b7bfcf8c88..feacbbdbb7 100644
--- a/spec/ruby/optional/capi/ext/string_spec.c
+++ b/spec/ruby/optional/capi/ext/string_spec.c
@@ -397,12 +397,16 @@ VALUE string_spec_RSTRING_PTR_read(VALUE self, VALUE str, VALUE path) {
rb_str_modify_expand(str, 30);
rb_ary_push(capacities, SIZET2NUM(rb_str_capacity(str)));
char *buffer = RSTRING_PTR(str);
- read(fd, buffer, 30);
+ if (read(fd, buffer, 30) < 0) {
+ rb_syserr_fail(errno, "read");
+ }
rb_str_modify_expand(str, 53);
rb_ary_push(capacities, SIZET2NUM(rb_str_capacity(str)));
char *buffer2 = RSTRING_PTR(str);
- read(fd, buffer2 + 30, 53 - 30);
+ if (read(fd, buffer2 + 30, 53 - 30) < 0) {
+ rb_syserr_fail(errno, "read");
+ }
rb_str_set_len(str, 53);
close(fd);