]> git.lizzy.rs Git - rust.git/commitdiff
Detect overflow in proc_macro_server subspan
authorTomasz Miąsko <tomasz.miasko@gmail.com>
Tue, 4 Aug 2020 00:00:00 +0000 (00:00 +0000)
committerTomasz Miąsko <tomasz.miasko@gmail.com>
Fri, 4 Sep 2020 19:35:56 +0000 (21:35 +0200)
compiler/rustc_expand/src/proc_macro_server.rs

index 39c82f97e0a39ce3503f084269ba7fba98285941..5a728bbda96c55aacc29352de342f5ae4fc935b1 100644 (file)
@@ -584,12 +584,12 @@ fn subspan(
 
         let start = match start {
             Bound::Included(lo) => lo,
-            Bound::Excluded(lo) => lo + 1,
+            Bound::Excluded(lo) => lo.checked_add(1)?,
             Bound::Unbounded => 0,
         };
 
         let end = match end {
-            Bound::Included(hi) => hi + 1,
+            Bound::Included(hi) => hi.checked_add(1)?,
             Bound::Excluded(hi) => hi,
             Bound::Unbounded => length,
         };