From 44ba4fd36248d8d496cb31cf2f33a0ad0c19b5a2 Mon Sep 17 00:00:00 2001 From: rhe Date: Tue, 20 Dec 2016 06:53:45 +0000 Subject: string.c: add missing size_t cast Add size_t cast to avoid signed integer overflow. r56157 ("string.c: avoid signed integer overflow", 2016-09-13) missed this. Suppresses UBSan. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57122 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- string.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'string.c') diff --git a/string.c b/string.c index 04737f0713..f9a93fd9c7 100644 --- a/string.c +++ b/string.c @@ -130,7 +130,7 @@ VALUE rb_cSymbol; #define RESIZE_CAPA_TERM(str,capacity,termlen) do {\ if (STR_EMBED_P(str)) {\ if (!STR_EMBEDDABLE_P(capacity, termlen)) {\ - char *const tmp = ALLOC_N(char, (capacity)+termlen);\ + char *const tmp = ALLOC_N(char, (size_t)(capacity) + (termlen));\ const long tlen = RSTRING_LEN(str);\ memcpy(tmp, RSTRING_PTR(str), tlen);\ RSTRING(str)->as.heap.ptr = tmp;\ -- cgit v1.2.3