Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
diff --git a/string.c b/string.c
index 435954d313..8a264acef4 100644
--- a/string.c
+++ b/string.c
@@ -9220,11 +9220,9 @@ rb_str_crypt(VALUE str, VALUE salt)
{
#ifdef HAVE_CRYPT_R
VALUE databuf;
- struct crypt_data *data;
-# define CRYPT_END() ALLOCV_END(databuf)
+ struct crypt_data data;
#else
extern char *crypt(const char *, const char *);
-# define CRYPT_END() (void)0
#endif
VALUE result;
const char *s, *saltp;
@@ -9253,21 +9251,18 @@ 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;
+ data.initialized = 0;
# endif
- res = crypt_r(s, saltp, data);
+ res = crypt_r(s, saltp, &data);
#else
res = crypt(s, saltp);
#endif
if (!res) {
int err = errno;
- CRYPT_END();
rb_syserr_fail(err, "crypt");
}
result = rb_str_new_cstr(res);
- CRYPT_END();
FL_SET_RAW(result, OBJ_TAINTED_RAW(str) | OBJ_TAINTED_RAW(salt));
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.