MRI-Binding: Fix typo that led to access of freed Color objects

Also fix my moronic variable naming in the InitCopy
functions that let to this mess up in the first place.
This commit is contained in:
Jonas Kulla 2013-12-15 10:13:58 +01:00
parent 5f290c5b11
commit 91c5eb1861
2 changed files with 13 additions and 13 deletions

View File

@ -199,14 +199,14 @@ rb_bool_new(bool value)
#define INITCOPY_FUN(Klass) \
RB_METHOD(Klass##InitializeCopy) \
{ \
VALUE orig; \
rb_get_args(argc, argv, "o", &orig, RB_ARG_END); \
if (!OBJ_INIT_COPY(self, orig)) /* When would this fail??*/\
VALUE origObj; \
rb_get_args(argc, argv, "o", &origObj, RB_ARG_END); \
if (!OBJ_INIT_COPY(self, origObj)) /* When would this fail??*/\
return self; \
Klass *k = getPrivateData<Klass>(orig); \
Klass *dup = 0; \
GUARD_EXC( dup = new Klass(*k); ) \
setPrivateData(self, dup); \
Klass *orig = getPrivateData<Klass>(origObj); \
Klass *k = 0; \
GUARD_EXC( k = new Klass(*orig); ) \
setPrivateData(self, k); \
return self; \
}

View File

@ -56,15 +56,15 @@ RB_METHOD(fontInitialize)
RB_METHOD(fontInitializeCopy)
{
VALUE orig;
rb_get_args(argc, argv, "o", &orig, RB_ARG_END);
VALUE origObj;
rb_get_args(argc, argv, "o", &origObj, RB_ARG_END);
if (!OBJ_INIT_COPY(self, orig))
if (!OBJ_INIT_COPY(self, origObj))
return self;
Font *f = getPrivateData<Font>(orig);
Font *dup = new Font(*f);
setPrivateData(self, dup);
Font *orig = getPrivateData<Font>(origObj);
Font *f = new Font(*orig);
setPrivateData(self, f);
/* Wrap property objects */
f->setColor(new Color(*f->getColor()));