diff options
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 18 |
1 files changed, 6 insertions, 12 deletions
@@ -8839,14 +8839,9 @@ rb_str_oct(VALUE str) static VALUE rb_str_crypt(VALUE str, VALUE salt) { -#undef LARGE_CRYPT_DATA #ifdef HAVE_CRYPT_R -# if defined SIZEOF_CRYPT_DATA && SIZEOF_CRYPT_DATA <= 256 - struct crypt_data cdata, *const data = &cdata; -# else -# define LARGE_CRYPT_DATA - struct crypt_data *data = ALLOC(struct crypt_data); -# endif + VALUE databuf; + struct crypt_data *data; #else extern char *crypt(const char *, const char *); #endif @@ -8877,6 +8872,7 @@ rb_str_crypt(VALUE str, VALUE salt) } #endif #ifdef HAVE_CRYPT_R + data = ALLOCV(databuf, sizeof(struct crypt_data)); # ifdef HAVE_STRUCT_CRYPT_DATA_INITIALIZED data->initialized = 0; # endif @@ -8885,17 +8881,15 @@ rb_str_crypt(VALUE str, VALUE salt) res = crypt(s, saltp); #endif if (!res) { -#ifdef LARGE_CRYPT_DATA +#ifdef HAVE_CRYPT_R int err = errno; - xfree(data); + ALLOCV_END(databuf); errno = err; #endif rb_sys_fail("crypt"); } result = rb_str_new_cstr(res); -#ifdef LARGE_CRYPT_DATA - xfree(data); -#endif + ALLOCV_END(databuf); FL_SET_RAW(result, OBJ_TAINTED_RAW(str) | OBJ_TAINTED_RAW(salt)); return result; } |