Patchwork D8019: rust-node: avoid meaningless read at the end of odd prefix

login
register
mail settings
Submitter phabricator
Date Jan. 28, 2020, 11:31 p.m.
Message ID <cd38f5c9cc17689144e1e9264b199626@localhost.localdomain>
Download mbox | patch
Permalink /patch/44711/
State Not Applicable
Headers show

Comments

phabricator - Jan. 28, 2020, 11:31 p.m.
Closed by commit rHGbe52b7372ec2: rust-node: avoid meaningless read at the end of odd prefix (authored by gracinet).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8019?vs=19648&id=19658

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8019/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D8019

AFFECTED FILES
  rust/hg-core/src/revlog/node.rs

CHANGE DETAILS




To: gracinet, #hg-reviewers
Cc: kevincox, mercurial-devel

Patch

diff --git a/rust/hg-core/src/revlog/node.rs b/rust/hg-core/src/revlog/node.rs
--- a/rust/hg-core/src/revlog/node.rs
+++ b/rust/hg-core/src/revlog/node.rs
@@ -223,6 +223,7 @@ 
     /// This is also the `i`th hexadecimal digit in numeric form,
     /// also called a [nybble](https://en.wikipedia.org/wiki/Nibble).
     pub fn get_nybble(&self, i: usize) -> u8 {
+        assert!(i < self.len());
         get_nybble(self.buf, i)
     }
 }