We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9757710 commit e3a2ffcCopy full SHA for e3a2ffc
src/main/c/cext/ruby.c
@@ -72,7 +72,11 @@ void *ruby_xmalloc(size_t size) {
72
}
73
74
void *ruby_xmalloc2(size_t n, size_t size) {
75
- return malloc(xmalloc2_size(n, size));
+ size_t total_size = xmalloc2_size(n, size);
76
+ if (total_size == 0) {
77
+ total_size = 1;
78
+ }
79
+ return malloc(xmalloc2_size(n, total_size));
80
81
82
void *ruby_xcalloc(size_t n, size_t size) {
@@ -96,6 +100,9 @@ void ruby_xfree(void *address) {
96
100
97
101
98
102
void *rb_alloc_tmp_buffer(volatile VALUE *store, long len) {
103
+ if (len == 0) {
104
+ len = 1;
105
99
106
void *ptr = malloc(len);
107
*((void**)store) = ptr;
108
return ptr;
0 commit comments