summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-09-06 21:15:23 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-09-06 21:15:23 -0700
commit1b5801edf62f8bfed9a2f88e88a0195518ba4976 (patch)
treef28c962166d31408728f22b855412e9475871a69 /lib.c
parentd8e5052e3714fbede5b52a1706ed22d7e745d849 (diff)
downloadtxr-1b5801edf62f8bfed9a2f88e88a0195518ba4976.tar.gz
txr-1b5801edf62f8bfed9a2f88e88a0195518ba4976.tar.bz2
txr-1b5801edf62f8bfed9a2f88e88a0195518ba4976.zip
linenoise: use checked allocator for strdup.
* lib.c (chk_strdup_utf8): New function. * lib.h (chk_strdup_utf8): Declared. * linenoise/linenoise.c (chk_strdup_utf8): Declared. (edit_history_next, linenoise, lino_hist_add): Use chk_strdup_utf8 instead of strdup.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index a3f0c6fb..fbabda77 100644
--- a/lib.c
+++ b/lib.c
@@ -1926,6 +1926,14 @@ wchar_t *chk_strdup(const wchar_t *str)
return copy;
}
+char *chk_strdup_utf8(const char *str)
+{
+ size_t nchar = strlen(str) + 1;
+ char *copy = coerce(char *, chk_malloc(nchar));
+ assert (!async_sig_enabled);
+ memcpy(copy, str, nchar);
+ return copy;
+}
val cons(val car, val cdr)
{