string.c: prefer rb_syserr_fail

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-11-14 03:02:58 +00:00
parent a48fac6e22
commit 73e41247b9

View File

@ -8842,8 +8842,10 @@ rb_str_crypt(VALUE str, VALUE salt)
#ifdef HAVE_CRYPT_R #ifdef HAVE_CRYPT_R
VALUE databuf; VALUE databuf;
struct crypt_data *data; struct crypt_data *data;
# define CRYPT_END() ALLOCV_END(databuf)
#else #else
extern char *crypt(const char *, const char *); extern char *crypt(const char *, const char *);
# define CRYPT_END() (void)0
#endif #endif
VALUE result; VALUE result;
const char *s, *saltp; const char *s, *saltp;
@ -8881,17 +8883,12 @@ rb_str_crypt(VALUE str, VALUE salt)
res = crypt(s, saltp); res = crypt(s, saltp);
#endif #endif
if (!res) { if (!res) {
#ifdef HAVE_CRYPT_R
int err = errno; int err = errno;
ALLOCV_END(databuf); CRYPT_END();
errno = err; rb_syserr_fail(err, "crypt");
#endif
rb_sys_fail("crypt");
} }
result = rb_str_new_cstr(res); result = rb_str_new_cstr(res);
#ifdef HAVE_CRYPT_R CRYPT_END();
ALLOCV_END(databuf);
#endif
FL_SET_RAW(result, OBJ_TAINTED_RAW(str) | OBJ_TAINTED_RAW(salt)); FL_SET_RAW(result, OBJ_TAINTED_RAW(str) | OBJ_TAINTED_RAW(salt));
return result; return result;
} }