Permalink
Browse files

Adding an error for toString instead of segfault if base is out of ra…

…nge.
  • Loading branch information...
1 parent 45eb53a commit b43bd9ecb328e0b90dd9f9616447f7e44cb522a0 @freeeve freeeve committed with Mar 4, 2013
Showing with 3 additions and 0 deletions.
  1. +3 −0 bigint.cc
View
@@ -261,6 +261,9 @@ BigInt::ToString(const Arguments& args)
if(args.Length() > 0) {
REQ_UINT64_ARG(0, tbase);
+ if(tbase < 2 || tbase > 62) {
+ return ThrowException(Exception::Error(String::New("Base should be between 2 and 62, inclusive")));
+ }
base = tbase;
}
char *to = mpz_get_str(0, base, *bigint->bigint_);

0 comments on commit b43bd9e

Please sign in to comment.