diff --git a/guile/src/core.c b/guile/src/core.c index 605c91f7a..38d573fa9 100644 --- a/guile/src/core.c +++ b/guile/src/core.c @@ -1,5 +1,5 @@ /* GnuTLS --- Guile bindings for GnuTLS. - Copyright (C) 2007-2014, 2016 Free Software Foundation, Inc. + Copyright (C) 2007-2014, 2016-2017 Free Software Foundation, Inc. GnuTLS is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -1428,22 +1428,19 @@ set_certificate_file (certificate_set_file_function_t set_file, { int err; char *c_file; - size_t c_file_len; gnutls_certificate_credentials_t c_cred; gnutls_x509_crt_fmt_t c_format; c_cred = scm_to_gnutls_certificate_credentials (cred, 1, FUNC_NAME); SCM_VALIDATE_STRING (2, file); - c_format = scm_to_gnutls_x509_certificate_format (format, 3, FUNC_NAME); - - c_file_len = scm_c_string_length (file); - c_file = alloca (c_file_len + 1); - (void) scm_to_locale_stringbuf (file, c_file, c_file_len + 1); - c_file[c_file_len] = '\0'; + c_format = scm_to_gnutls_x509_certificate_format (format, 3, FUNC_NAME); + c_file = scm_to_locale_string (file); err = set_file (c_cred, c_file, c_format); + free (c_file); + if (EXPECT_FALSE (err < 0)) scm_gnutls_error (err, FUNC_NAME);