Hi,

2011/4/27 Måns Rullgård <[email protected]>:
> "Sean McGovern" <[email protected]> writes:
>
>> On Solaris, malloc(0) returns a NULL pointer. This, and returning a
>> valid pointer of 0 length are both considered POSIX-compliant.
>
> Thus there is no need to protect against it.  The result of malloc(0)
> should never be dereferenced, so whether it is null or not doesn't matter.
>
> If this patch is intended to fix the Darwin breakage, I am very much
> against it.

Yes.

It's not malloc, it's posix_memalign(). On all systems that we test,
memalign or posix_memalign() with size=0 and alignment=16 returns a
non-NULL pointer that can be free()ed. I've tested it and some of my
patches even show that blindly assume the allocation to succeed. And
it does.

On Mac, alignment=32 somehow breaks this. I don't know why, but
av_malloc(0) can return NULL, and we don't handle that at all. We
either return an error, which is silly, because av_malloc(0) needs no
memory anyway, or we don't check it at all. Not sure which is worse.

All of this is in init code. If wanted, I can split MPV_common_init()
in two parts, one to be run before width/height are known and a second
after, but that's a lot of effort for broken code that I do not really
wish to maintain. If you have other ideas, let me know.

Ronald
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to