• Martin Storsjö's avatar
    mem: Consistently return NULL for av_malloc(0) · 14f063d2
    Martin Storsjö authored
    Plain POSIX malloc(0) is allowed to return either NULL or a
    non-NULL pointer. The calling code should be ready to handle
    a NULL return as a correct return (instead of a failure) if the size
    to allocate was 0 - this makes sure the condition is handled
    in a consistent way across platforms.
    
    This also avoids calling posix_memalign(&ptr, 32, 0) on OS X,
    which returns an invalid pointer (a non-NULL pointer that causes
    crashes when passed to av_free).
    
    Abort in debug mode, to help track down issues related to
    incorrect handling of this case.
    Signed-off-by: 's avatarMartin Storsjö <martin@martin.st>
    14f063d2
mem.c 4.27 KB