Conditional operator does not typecheck

Bug #1060341 reported by Michael Tautschnig
6
This bug affects 1 person
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_assign(lvalue, rvalue) \
    lvalue = ((lvalue ? g_object_unref (lvalue) : lvalue), rvalue)

to

#define katze_object_assign(lvalue, rvalue) \
    lvalue = ((lvalue ? g_object_unref (lvalue) : (void)0), rvalue)

as the returned value is always rvalue anyway.

Best,
Michael

Revision history for this message
Cris Dywan (kalikiana) wrote :

I'm not sure that I see the practical consequence, but given it's a trivial fix, why not. Thanks!

Changed in midori:
status: New → Fix Committed
Changed in midori:
status: Fix Committed → Fix Released
status: Fix Released → Fix Committed
milestone: none → 0.5.1
Cris Dywan (kalikiana)
Changed in midori:
status: Fix Committed → Fix Released
Cody Garver (codygarver)
Changed in midori:
milestone: 0.5.2 → none
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.