summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/bigdecimal/bigdecimal.c4
-rw-r--r--ext/json/generator/generator.c1
-rw-r--r--ext/zlib/zlib.c1
3 files changed, 5 insertions, 1 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 9601d1c70f..266e85311e 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -2427,7 +2427,9 @@ BigDecimal_initialize_copy(VALUE self, VALUE other)
Real *pv = rb_check_typeddata(self, &BigDecimal_data_type);
Real *x = rb_check_typeddata(other, &BigDecimal_data_type);
- DATA_PTR(self) = VpCopy(pv, x);
+ if (self != other) {
+ DATA_PTR(self) = VpCopy(pv, x);
+ }
return self;
}
diff --git a/ext/json/generator/generator.c b/ext/json/generator/generator.c
index 5df8de1ddf..f32f866419 100644
--- a/ext/json/generator/generator.c
+++ b/ext/json/generator/generator.c
@@ -957,6 +957,7 @@ static VALUE cState_init_copy(VALUE obj, VALUE orig)
{
JSON_Generator_State *objState, *origState;
+ if (obj == orig) return obj;
Data_Get_Struct(obj, JSON_Generator_State, objState);
Data_Get_Struct(orig, JSON_Generator_State, origState);
if (!objState) rb_raise(rb_eArgError, "unallocated JSON::State");
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index d3f29889b1..9294c2c857 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -1554,6 +1554,7 @@ rb_deflate_init_copy(VALUE self, VALUE orig)
Data_Get_Struct(self, struct zstream, z1);
z2 = get_zstream(orig);
+ if (z1 == z2) return self;
err = deflateCopy(&z1->stream, &z2->stream);
if (err != Z_OK) {
raise_zlib_error(err, 0);