Conditional operator does not typecheck
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Midori Web Browser |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
While building your package using our research compiler infrastructure we noticed that the condition operator resulting from expansion of katze_object_assign of katze/katze-utils.h does not typecheck:
The return type of g_object_unref is void, but lvalue may be of an abitrary pointer type. Yet the C standard requires that the second and third argument of the conditional operator ?: are both void or compatible pointer types (there are several other cases, see 6.5.15 of the C Standard). Failing this, the compiler may produce arbitrary code.
The best way to fix this is likely changing
#define katze_object_
lvalue = ((lvalue ? g_object_unref (lvalue) : lvalue), rvalue)
to
#define katze_object_
lvalue = ((lvalue ? g_object_unref (lvalue) : (void)0), rvalue)
as the returned value is always rvalue anyway.
Best,
Michael
Changed in midori: | |
status: | Fix Committed → Fix Released |
status: | Fix Released → Fix Committed |
milestone: | none → 0.5.1 |
Changed in midori: | |
status: | Fix Committed → Fix Released |
Changed in midori: | |
milestone: | 0.5.2 → none |
I'm not sure that I see the practical consequence, but given it's a trivial fix, why not. Thanks!