aboutsummaryrefslogtreecommitdiffstats
path: root/ext/openssl/ossl_cipher.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-29 05:55:02 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-29 05:55:02 +0000
commit0b8ad915b8c0fef1833716784dd94a0ef6caec92 (patch)
treeed014c958a0f622db02af64186def2c70e4c00ba /ext/openssl/ossl_cipher.c
parentdfe11b5df4c8c37f07685da46eea7670dcb562be (diff)
downloadruby-0b8ad915b8c0fef1833716784dd94a0ef6caec92.tar.gz
openssl: wrapper object before alloc
* ext/openssl: make wrapper objects before allocating structs to get rid of potential memory leaks. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50673 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/openssl/ossl_cipher.c')
-rw-r--r--ext/openssl/ossl_cipher.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/ext/openssl/ossl_cipher.c b/ext/openssl/ossl_cipher.c
index 72eaa3f31d..3e92d65668 100644
--- a/ext/openssl/ossl_cipher.c
+++ b/ext/openssl/ossl_cipher.c
@@ -10,8 +10,8 @@
*/
#include "ossl.h"
-#define WrapCipher(obj, klass, ctx) \
- (obj) = TypedData_Wrap_Struct((klass), &ossl_cipher_type, (ctx))
+#define NewCipher(klass) \
+ TypedData_Wrap_Struct((klass), &ossl_cipher_type, 0)
#define MakeCipher(obj, klass, ctx) \
(obj) = TypedData_Make_Struct((klass), EVP_CIPHER_CTX, &ossl_cipher_type, (ctx))
#define AllocCipher(obj, ctx) \
@@ -98,11 +98,7 @@ ossl_cipher_memsize(const void *ptr)
static VALUE
ossl_cipher_alloc(VALUE klass)
{
- VALUE obj;
-
- WrapCipher(obj, klass, 0);
-
- return obj;
+ return NewCipher(klass);
}
/*