summaryrefslogtreecommitdiff
path: root/ext/openssl/ossl_ns_spki.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
commit451fe269e5ab1270a53ac7bdeceabe47fd431f95 (patch)
treeed014c958a0f622db02af64186def2c70e4c00ba /ext/openssl/ossl_ns_spki.c
parent5924f9a684ace630d3658a0d6e52270e3686ca9f (diff)
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_ns_spki.c')
-rw-r--r--ext/openssl/ossl_ns_spki.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/ext/openssl/ossl_ns_spki.c b/ext/openssl/ossl_ns_spki.c
index b3e0ab8..94e0667 100644
--- a/ext/openssl/ossl_ns_spki.c
+++ b/ext/openssl/ossl_ns_spki.c
@@ -10,11 +10,13 @@
*/
#include "ossl.h"
-#define WrapSPKI(klass, obj, spki) do { \
+#define NewSPKI(klass) \
+ TypedData_Wrap_Struct((klass), &ossl_netscape_spki_type, 0)
+#define SetSPKI(obj, spki) do { \
if (!(spki)) { \
ossl_raise(rb_eRuntimeError, "SPKI wasn't initialized!"); \
} \
- (obj) = TypedData_Wrap_Struct((klass), &ossl_netscape_spki_type, (spki)); \
+ RTYPEDDATA_DATA(obj) = (spki); \
} while (0)
#define GetSPKI(obj, spki) do { \
TypedData_Get_Struct((obj), NETSCAPE_SPKI, &ossl_netscape_spki_type, (spki)); \
@@ -58,10 +60,11 @@ ossl_spki_alloc(VALUE klass)
NETSCAPE_SPKI *spki;
VALUE obj;
+ obj = NewSPKI(klass);
if (!(spki = NETSCAPE_SPKI_new())) {
ossl_raise(eSPKIError, NULL);
}
- WrapSPKI(klass, obj, spki);
+ SetSPKI(obj, spki);
return obj;
}