nitlanguage
/
nit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
8386ac8
)
lib/core: add failsafe to UTF8Codec::decode_string
author
Lucas Bajolet
<lucas.bajolet@gmail.com>
Fri, 11 May 2018 00:50:14 +0000
(20:50 -0400)
committer
Lucas Bajolet
<lucas.bajolet@gmail.com>
Fri, 11 May 2018 03:16:40 +0000
(23:16 -0400)
Calling decode_string on the UTF-8 codec with a negative legth would
cause memmove to crash the program with a segfault.
Adding an assert gives more information on what went wrong and will help
investigate future bugs.
Signed-off-by: Lucas Bajolet <lucas.bajolet@gmail.com>
lib/core/codecs/utf8.nit
patch
|
blob
|
history
diff --git
a/lib/core/codecs/utf8.nit
b/lib/core/codecs/utf8.nit
index
43f6235
..
d4d4a38
100644
(file)
--- a/
lib/core/codecs/utf8.nit
+++ b/
lib/core/codecs/utf8.nit
@@
-68,6
+68,7
@@
private class UTF8Codec
end
redef fun decode_string(ns, len) do
+ assert len >= 0
var ret = ns.to_s_unsafe(len, copy=false)
var rit = ret.as(FlatString).items
if rit == ns then