This repository was archived by the owner on Nov 6, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -367,18 +367,18 @@ impl Impl for ModexpImpl {
367367 let exp_len = read_len ( & mut reader) ;
368368 let mod_len = read_len ( & mut reader) ;
369369
370- // read the numbers themselves.
371- let mut buf = vec ! [ 0 ; max( mod_len, max( base_len, exp_len) ) ] ;
372- let mut read_num = |len| {
373- reader. read_exact ( & mut buf[ ..len] ) . expect ( "reading from zero-extended memory cannot fail; qed" ) ;
374- BigUint :: from_bytes_be ( & buf[ ..len] )
375- } ;
376-
377- let base = read_num ( base_len) ;
378370 // Gas formula allows arbitrary large exp_len when base and modulus are empty, so we need to handle empty base first.
379371 let r = if base_len == 0 && mod_len == 0 {
380372 BigUint :: zero ( )
381373 } else {
374+ // read the numbers themselves.
375+ let mut buf = vec ! [ 0 ; max( mod_len, max( base_len, exp_len) ) ] ;
376+ let mut read_num = |len| {
377+ reader. read_exact ( & mut buf[ ..len] ) . expect ( "reading from zero-extended memory cannot fail; qed" ) ;
378+ BigUint :: from_bytes_be ( & buf[ ..len] )
379+ } ;
380+
381+ let base = read_num ( base_len) ;
382382 let exp = read_num ( exp_len) ;
383383 let modulus = read_num ( mod_len) ;
384384 modexp ( base, exp, modulus)
You can’t perform that action at this time.
0 commit comments