null pointer passed as argument 2 to memcpy(), which is declared to never be null

Milan Crha mcrha at redhat.com
Wed Jan 17 09:55:49 PST 2018


	Hi,
while have compiled libical and others with some code sanitizing
options I noticed a runtime error on a console:

> libical/src/libical/icalarray.c:181:9: runtime error: null pointer
> passed as argument 2, which is declared to never be null

That line calls memcpy() unconditionally. The thing is that for the
first time, when the array is empty, the currently allocated chunks are
NULL, hence the runtime warning.

Attached is a trivial patch which fixes it.

You can use realloc() instead, which accepts NULL, but I didn't went
that far.
	Bye,
	Milan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ical.patch
Type: text/x-patch
Size: 1009 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/libical-devel/attachments/20180117/5d5ebca0/attachment.bin>


More information about the libical-devel mailing list