Bug 31581 - tp_group_mixin_remove_members_with_reason breaks API guarantees
Summary: tp_group_mixin_remove_members_with_reason breaks API guarantees
Status: RESOLVED FIXED
Alias: None
Product: Telepathy
Classification: Unclassified
Component: tp-glib (show other bugs)
Version: 0.12
Hardware: Other All
: medium normal
Assignee: Simon McVittie
QA Contact: Telepathy bugs list
URL: http://git.collabora.co.uk/?p=user/sm...
Whiteboard: review+
Keywords: patch
Depends on:
Blocks:
 
Reported: 2010-11-12 06:54 UTC by Jonny Lamb
Modified: 2010-11-16 03:29 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Jonny Lamb 2010-11-12 06:54:05 UTC
I told my grandmother that she was fine to trust the highly documented telepathy-glib library's API guarantees and that Simon McVittie knew what const meant. I don't like lying to my grandmother, but lying to my grandmother is what I have done.

tp_group_mixin_remove_members_with_reason takes a const GArray *contacts but then modifies the contents of this const GArray*. Correct me if I'm wrong, but const is for more than looking pretty in function arguments.

Perhaps you meant const GArray * const * const * GArray * const?

(btw, the offending commit is:

commit a36f21cbec16a1c9a92075d6c26827861e8ab53f
Author: Simon McVittie <simon.mcvittie@collabora.co.uk>
Date:   Fri May 21 13:16:33 2010 +0100

    TpGroupMixin: when removing members, don't raise an error if it's a no-op

    This is awkward if two clients both try to remove the same member at the
    same time, for instance.
)
Comment 1 Simon McVittie 2010-11-15 04:36:33 UTC
(In reply to comment #0)
> tp_group_mixin_remove_members_with_reason takes a const GArray *contacts but
> then modifies the contents of this const GArray*.

Oops. I'll get on that.
Comment 2 Simon McVittie 2010-11-15 04:52:36 UTC
I was surprised the compiler didn't catch this, but it turns out to be because g_array_index contains a cast to (TpHandle *), which casts away the constness at the same time as correcting the type.
Comment 3 Jonny Lamb 2010-11-15 05:30:01 UTC
(In reply to comment #2)
> I was surprised the compiler didn't catch this, but it turns out to be because
> g_array_index contains a cast to (TpHandle *), which casts away the constness
> at the same time as correcting the type.

Okay, I'll let you off this time.
Comment 4 Simon McVittie 2010-11-16 03:29:39 UTC
Fixed in git for 0.12.4 and 0.13.6


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.