mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
5924f9a684
commit
451fe269e5
23 changed files with 226 additions and 124 deletions
|
@ -21,11 +21,13 @@ extern const rb_data_type_t ossl_evp_pkey_type;
|
|||
#define OSSL_PKEY_SET_PUBLIC(obj) rb_iv_set((obj), "private", Qfalse)
|
||||
#define OSSL_PKEY_IS_PRIVATE(obj) (rb_iv_get((obj), "private") == Qtrue)
|
||||
|
||||
#define WrapPKey(klass, obj, pkey) do { \
|
||||
#define NewPKey(klass) \
|
||||
TypedData_Wrap_Struct((klass), &ossl_evp_pkey_type, 0)
|
||||
#define SetPKey(obj, pkey) do { \
|
||||
if (!(pkey)) { \
|
||||
rb_raise(rb_eRuntimeError, "PKEY wasn't initialized!"); \
|
||||
} \
|
||||
(obj) = TypedData_Wrap_Struct((klass), &ossl_evp_pkey_type, (pkey)); \
|
||||
RTYPEDDATA_DATA(obj) = (pkey); \
|
||||
OSSL_PKEY_SET_PUBLIC(obj); \
|
||||
} while (0)
|
||||
#define GetPKey(obj, pkey) do {\
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue