Skip to content

guard zero digit count in GenerateCountedDigits - #306

Open
Ramya-9353 wants to merge 1 commit into
google:masterfrom
Ramya-9353:bignum-counted-digits-zero
Open

guard zero digit count in GenerateCountedDigits#306
Ramya-9353 wants to merge 1 commit into
google:masterfrom
Ramya-9353:bignum-counted-digits-zero

Conversation

@Ramya-9353

Copy link
Copy Markdown
Contributor

AddressSanitizer, -DNDEBUG build:

==ERROR: AddressSanitizer: heap-buffer-overflow ... WRITE of size 1
    #0 GenerateCountedDigits bignum-dtoa.cc:304
    #1 BignumDtoa bignum-dtoa.cc:161
located 1 bytes before 8-byte region [...]

Reached from the public API BignumDtoa(v, BIGNUM_DTOA_PRECISION, 0, buffer, &length, &point). GenerateCountedDigits only asserts count >= 0 and then stores the final digit at buffer[count - 1], so count == 0 writes buffer[-1]. DoubleToStringConverter::DoubleToAscii already special-cases precision mode with zero digits one layer up; BignumDtoa did not. Return an empty representation when count == 0, before the store.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant