summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2018-08-11 14:42:09 +0200
committerEugen Wissner <belka@caraus.de>2018-08-11 14:42:09 +0200
commitba5833318b3168685b0349aa41f487422fcb62d5 (patch)
tree27d2db949c4f645931c4714b1e2d791ba87fa85a /source
parent918d8f54503fb1035ffb3465770e6a107950fc99 (diff)
downloadtanya-ba5833318b3168685b0349aa41f487422fcb62d5.tar.gz
conv: Fix taking out of range chars for hex values
Diffstat (limited to 'source')
-rw-r--r--source/tanya/conv.d13
1 files changed, 11 insertions, 2 deletions
diff --git a/source/tanya/conv.d b/source/tanya/conv.d
index 561ccce..bce5401 100644
--- a/source/tanya/conv.d
+++ b/source/tanya/conv.d
@@ -308,11 +308,11 @@ do
{
digit = range.front - 'W';
}
- else if (range.front >= 'A')
+ else if (range.front >= 'A' && range.front <= 'Z')
{
digit = range.front - '7';
}
- else if (range.front >= '0')
+ else if (range.front >= '0' && range.front <= '9')
{
digit = range.front - '0';
}
@@ -360,6 +360,15 @@ do
return n;
}
+// ':' is not a hex value
+@nogc nothrow pure @safe unittest
+{
+ string colon = ":";
+ auto actual = readIntegral!ubyte(colon, 16);
+ assert(actual == 0);
+ assert(colon.length == 1);
+}
+
// reads ubyte.max
@nogc nothrow pure @safe unittest
{