summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-03-05 02:58:59 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-03-05 02:58:59 +0000
commit89e70fe8e7d6b6253e5aa84c2b414957a22a3d7d (patch)
treee3adaf785c96e77a071486c0515b91155057db0a
parent5e4ac976b017b660502db5d265edb9aaf2b826b9 (diff)
ossl.c: NULL check
* ext/openssl/ossl.c (ossl_make_error): check NULL for unknown error reasons with old OpenSSL, and insert a colon iff formatted message is not empty. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45271 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--ext/openssl/ossl.c5
2 files changed, 9 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 3fa801b179..06b002cb30 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Wed Mar 5 11:58:30 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * ext/openssl/ossl.c (ossl_make_error): check NULL for unknown
+ error reasons with old OpenSSL, and insert a colon iff formatted
+ message is not empty.
+
Wed Mar 5 00:42:00 2014 Kazuki Tsujimoto <kazuki@callcc.net>
* ext/pathname/lib/pathname.rb (Pathname#find): add "ignore_error"
diff --git a/ext/openssl/ossl.c b/ext/openssl/ossl.c
index 614d2fa6f7..7f9105c117 100644
--- a/ext/openssl/ossl.c
+++ b/ext/openssl/ossl.c
@@ -312,10 +312,11 @@ ossl_make_error(VALUE exc, const char *fmt, va_list args)
else
msg = ERR_reason_error_string(e);
if (NIL_P(str)) {
- str = rb_str_new_cstr(msg);
+ if (msg) str = rb_str_new_cstr(msg);
}
else {
- rb_str_cat2(rb_str_cat2(str, ": "), msg);
+ if (RSTRING_LEN(str)) rb_str_cat2(str, ": ");
+ rb_str_cat2(str, msg ? msg : "(null)");
}
}
if (dOSSL == Qtrue){ /* show all errors on the stack */