diff options
author | Andy Wingo <wingo@pobox.com> | 2011-09-10 11:38:25 -0700 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2011-09-10 11:38:25 -0700 |
commit | fe1336405062c69ff08fd7ad0d98c3f2aca7766f (patch) | |
tree | 7626d7f85770ca7b8ada6ef266243beab4e49f67 /libguile/strings.c | |
parent | cb7bcfca3520a147881e4b7f052b68b88a740bf1 (diff) | |
download | guile-fe1336405062c69ff08fd7ad0d98c3f2aca7766f.tar.gz |
fix scm_to_latin1_stringn for substrings
* libguile/strings.c (scm_to_latin1_stringn): Fix for substrings.
* test-suite/standalone/Makefile.am:
* test-suite/standalone/test-scm-to-latin1-string.c: Add test case.
Thanks to David Hansen for the bug report and test case, and Stefan
Israelsson Tampe for the fix.
Diffstat (limited to 'libguile/strings.c')
-rw-r--r-- | libguile/strings.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/libguile/strings.c b/libguile/strings.c index 5b15ddcb3..666a9516b 100644 --- a/libguile/strings.c +++ b/libguile/strings.c @@ -1779,14 +1779,16 @@ scm_to_latin1_stringn (SCM str, size_t *lenp) if (scm_i_is_narrow_string (str)) { + size_t len = scm_i_string_length (str); + if (lenp) - *lenp = scm_i_string_length (str); + *lenp = len; - result = scm_strdup (scm_i_string_data (str)); + result = scm_strndup (scm_i_string_data (str), len); } else result = scm_to_stringn (str, lenp, NULL, - SCM_FAILED_CONVERSION_ERROR); + SCM_FAILED_CONVERSION_ERROR); return result; } |