Skip to content
  • Simon McVittie's avatar
    Avoid calling memcpy with n == 0 · 6649af5e
    Simon McVittie authored
    
    
    Some callers of these functions ask to copy 0 items from a NULL source,
    which would be valid if they were copied in a loop (because NULL would
    never be dereferenced), but is declared to be undefined behaviour for
    Standard C memcpy. Guard the call to memcpy so that we only call it
    if we have more than 0 items, and therefore should have a non-NULL
    source pointer.
    
    Detected by running a subset of the test suite with
    -Dsanitize=address,undefined on x86_64.
    
    Signed-off-by: default avatarSimon McVittie <smcv@debian.org>
    6649af5e
Loading