summaryrefslogtreecommitdiff
path: root/external/liborcus/0001-Prevent-unsigned-integer-underflow.patch
blob: 3353857a2d107b67a2ad9bf5f535cad62d88a291 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
From 1967be013804f4f578b53659d7ef459b4c35de9f Mon Sep 17 00:00:00 2001
From: Kohei Yoshida <kohei.yoshida@gmail.com>
Date: Wed, 7 Nov 2018 21:08:40 -0500
Subject: [PATCH] Prevent unsigned integer underflow.

(cherry picked from commit 40bbce85048b77c545103af124f3d9831dd4a458)
---
 src/parser/parser_base.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/parser/parser_base.cpp b/src/parser/parser_base.cpp
index 586d495f..9d426efb 100644
--- a/src/parser/parser_base.cpp
+++ b/src/parser/parser_base.cpp
@@ -120,7 +120,8 @@ double parser_base::parse_double()
 
 size_t parser_base::remaining_size() const
 {
-    return std::distance(mp_char, mp_end) - 1;
+    size_t n = std::distance(mp_char, mp_end);
+    return n ? (n - 1) : 0;
 }
 
 std::ptrdiff_t parser_base::offset() const
-- 
2.17.1