|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
While running the code example locally, I ran into a bug where
icalcomponent_vanew() would crash, but only when I was using
more than 4 variable arguments. Code to reproduce is:
icalcomponent_vanew(
ICAL_VEVENT_COMPONENT,
icalproperty_new_dtstamp(atime),
icalproperty_new_dtstamp(atime),
icalproperty_new_dtstamp(atime),
icalproperty_new_dtstamp(atime),
icalproperty_new_dtstamp(atime),
0);
My machine is a 64-bit OS X machine. After a bit of fiddling
and experimentation I think I found the cause, which is that
on my machine, `sizeof(int) == 4` whereas `sizeof(void*) == 8`.
In icalcomponent_add_children(), varargs are interpreted
as `void *`, and checked for equality with 0 (therefore,
the is automagically cast to a `void*`.
As to why this only happened when there are more than 4
varargs, my best guess is that since the first N arguments
are passed via registers on x86-64, it would be passed as
a zeroed-register, whereas any arguments after that would be
passed on the stack, where obviously anything that is on
the stack after the 4-byte 0 would make this code crash.
This should probably be marked in the documentation for
the vanew functions (if it hasn't already).
|