From 73e41247b93a74c9b2ec95a374736fdb98fcaac5 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 14 Nov 2017 03:02:58 +0000 Subject: [PATCH] string.c: prefer rb_syserr_fail git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- string.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/string.c b/string.c index 6f91cd3878..806436e327 100644 --- a/string.c +++ b/string.c @@ -8842,8 +8842,10 @@ rb_str_crypt(VALUE str, VALUE salt) #ifdef HAVE_CRYPT_R VALUE databuf; struct crypt_data *data; +# define CRYPT_END() ALLOCV_END(databuf) #else extern char *crypt(const char *, const char *); +# define CRYPT_END() (void)0 #endif VALUE result; const char *s, *saltp; @@ -8881,17 +8883,12 @@ rb_str_crypt(VALUE str, VALUE salt) res = crypt(s, saltp); #endif if (!res) { -#ifdef HAVE_CRYPT_R int err = errno; - ALLOCV_END(databuf); - errno = err; -#endif - rb_sys_fail("crypt"); + CRYPT_END(); + rb_syserr_fail(err, "crypt"); } result = rb_str_new_cstr(res); -#ifdef HAVE_CRYPT_R - ALLOCV_END(databuf); -#endif + CRYPT_END(); FL_SET_RAW(result, OBJ_TAINTED_RAW(str) | OBJ_TAINTED_RAW(salt)); return result; }