Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix decoding the hints dictionary. #158

Closed
wants to merge 1 commit into from
Closed

Conversation

raveit65
Copy link
Member

Back port of
8dad8a7

@flexiondotorg @vkareh @kbrenneman
Please take a look at it. Commit from master didn't clean apply with a cherry-pick.

Back port of
8dad8a7

g_variant_lookup works like g_variant_get, so using a format string of "v" only
works if the type is actually a GVariant. Since none of the hints have GVariant
values, that means every g_variant_get with a "v" format will fail.

Fix all of the g_variant_lookup calls so that they either unpack a value
directly, or use a "@" prefix when it's more convenient to fetch the value as
a GVariant pointer.

In addition, in cases where we do fetch a GVariant, make sure that we
unreference it afterward.
Copy link
Member

@vkareh vkareh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works fine for me

}
/* deal with x, and y hints */
else if (g_variant_lookup(hints, "x", "v", &data))
else if (g_variant_lookup(hints, "x", "i", &x))
{
x = g_variant_get_int32 (data);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This g_variant_get_int32 call needs to be removed. The g_variant_lookup call before already assigns the value to x. data is going to be either uninitialized or freed at this point.

{
x = g_variant_get_int32 (data);

if (g_variant_lookup(hints, "y", "v", &data))
if (g_variant_lookup(hints, "y", "i", &y))
{
y = g_variant_get_int32 (data);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above -- the g_variant_lookup call assigns to y, so remove the g_variant_get_int32 call.

@kbrenneman
Copy link

Two g_variant_get_int32 calls that were removed in the original patch got left in this one.

If it makes things easier, I've also got a local branch with this fix on top of 1.22 -- I actually started there because it was easier to diagnose and test on my system. I can submit a PR with that if anyone wants.

@vkareh
Copy link
Member

vkareh commented Sep 17, 2019 via email

@kbrenneman
Copy link

Okay, I just posted #159.

@raveit65
Copy link
Member Author

Thanks, i will close this one.

@raveit65 raveit65 closed this Sep 17, 2019
@raveit65 raveit65 deleted the 1.22-fix-decoding-hints branch September 17, 2019 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants