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

Avoid calling memcpy with NULL pointers #305

Merged
merged 1 commit into from
Apr 17, 2015

Commits on Apr 16, 2015

  1. Avoid calling memcpy with NULL pointers

    According to the C/C++ standards, calling `memcpy(NULL, NULL, 0)` is
    undefined behaviour. Recent GCC versions may rely on this by optimizing
    NULL pointer checks more aggressively, see [1].
    
    This patch tries to avoid calling std::memcpy with zero elements.
    As a side effect, explicitly return NULL when requesting an empty block
    from MemoryPoolAllocator::Malloc.
    
    This may be related to Tencent#301.
    
    [1] https://gcc.gnu.org/gcc-4.9/porting_to.html
    pah committed Apr 16, 2015
    Configuration menu
    Copy the full SHA
    0c5c153 View commit details
    Browse the repository at this point in the history