aboutsummaryrefslogtreecommitdiffstats
path: root/vm_callinfo.h
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2020-04-12 15:19:06 -0400
committerGitHub <noreply@github.com>2020-04-12 15:19:06 -0400
commit82fdffc5ec0ecffc2e49128775d7c09ed43ba59d (patch)
tree9095f4918dd132171ea875b75bfdfa26b0fe2803 /vm_callinfo.h
parentf2c3848a5bf2bec0b27a6035c4b7399594c32509 (diff)
downloadruby-82fdffc5ec0ecffc2e49128775d7c09ed43ba59d.tar.gz
Avoid UB with flexible array member
Accessing past the end of an array is technically UB. Use C99 flexible array member instead to avoid the UB and simplify allocation size calculation. See also: DCL38-C in the SEI CERT C Coding Standard
Diffstat (limited to 'vm_callinfo.h')
-rw-r--r--vm_callinfo.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/vm_callinfo.h b/vm_callinfo.h
index 013811d15e..b3de14dcab 100644
--- a/vm_callinfo.h
+++ b/vm_callinfo.h
@@ -33,14 +33,14 @@ enum vm_call_flag_bits {
struct rb_callinfo_kwarg {
int keyword_len;
- VALUE keywords[1];
+ VALUE keywords[];
};
static inline size_t
rb_callinfo_kwarg_bytes(int keyword_len)
{
return rb_size_mul_add_or_raise(
- keyword_len - 1,
+ keyword_len,
sizeof(VALUE),
sizeof(struct rb_callinfo_kwarg),
rb_eRuntimeError);