]> gitweb.factorcode.org Git - factor.git/blobdiff - core/math/parser/parser.factor
math.parser: require hex-string>bytes to have even digits
[factor.git] / core / math / parser / parser.factor
index 2e1d5a4b0f4dd3447665859e70d5587088e8ecd5..778c754981c151c02527627f753bc75a14bfedd7 100644 (file)
@@ -1019,8 +1019,10 @@ M: float >base
 
 : # ( n -- ) number>string % ; inline
 
+ERROR: invalid-hex-string-length n ;
+
 : hex-string>bytes ( hex-string -- bytes )
-    dup length 2/ <byte-array> [
+    dup length dup even? [ invalid-hex-string-length ] unless 2/ <byte-array> [
         [
             [ digit> ] 2dip over even? [
                 [ 16 * ] [ 2/ ] [ set-nth-unsafe ] tri*