Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for integer overflows when allocating memory #3549

Merged
merged 1 commit into from
Aug 27, 2019

Commits on Aug 26, 2019

  1. Check for integer overflows when allocating memory

    Context: android/ndk#294
    Context: android/ndk#295
    Context: https://bugs.llvm.org/show_bug.cgi?id=16404
    
    Add a couple of functions to `Utils` taking advantage of the compiler builtin
    functions to perform integer addition and multiplication while checking for
    overflows. If an overflow is detected, the application is terminated.
    
    Due to a bug in Android NDK's clang, the multiplication is not performed using
    "open" types but rather, currently, only `size_t` for the multiplication
    operands.
    
    Using a template for them would result in a link error as the compiler would
    generate code to use 128-bit integers to perform the operation, attempting to
    call the `__muloti4` intrinsic function which is usually defined in `libgcc`,
    `libcompiler_rt` or `libcompiler_rt-extras` libraries. In the NDK case the
    64-bit targets do not contain implementation of the function in neither of the
    libraries mentioned above.
    grendello committed Aug 26, 2019
    Configuration menu
    Copy the full SHA
    8892d33 View commit details
    Browse the repository at this point in the history