From dc89521801699ee504141f566d9201db86a35235 Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Sun, 24 Aug 2014 16:49:20 +0900 Subject: [PATCH] sexp_c_string returns #f for NULL --- sexp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sexp.c b/sexp.c index 4e9b96e7..c850611d 100644 --- a/sexp.c +++ b/sexp.c @@ -1045,8 +1045,11 @@ sexp sexp_make_string_op (sexp ctx, sexp self, sexp_sint_t n, sexp len, sexp ch) } sexp sexp_c_string (sexp ctx, const char *str, sexp_sint_t slen) { - sexp_sint_t len = ((slen >= 0) ? slen : strlen(str)); - sexp s = sexp_make_string(ctx, sexp_make_fixnum(len), SEXP_VOID); + sexp_sint_t len; + sexp s; + if (str == NULL) return SEXP_FALSE; + len = ((slen >= 0) ? slen : strlen(str)); + s = sexp_make_string(ctx, sexp_make_fixnum(len), SEXP_VOID); if (sexp_exceptionp(s)) return s; memcpy(sexp_string_data(s), str, len); sexp_string_data(s)[len] = '\0';