diff options
author | jgeboski <jgeboski@gmail.com> | 2015-12-31 16:11:55 -0500 |
---|---|---|
committer | jgeboski <jgeboski@gmail.com> | 2016-01-01 19:37:58 -0500 |
commit | 56d729851a1a431cbdd28b9c5626fd7e1c86d9e0 (patch) | |
tree | 8e3558e5f14c0a9d5c392132317b837da5e6e527 /facebook/facebook-api.h | |
parent | fd4e4f7195c0fe93713c25d40ce6edaf600a00c6 (diff) | |
download | bitlbee-facebook-56d729851a1a431cbdd28b9c5626fd7e1c86d9e0.tar.gz bitlbee-facebook-56d729851a1a431cbdd28b9c5626fd7e1c86d9e0.tar.bz2 bitlbee-facebook-56d729851a1a431cbdd28b9c5626fd7e1c86d9e0.tar.xz |
facebook-api: properly handle optional Thrift fields and scoping
The plugin is required to read Thrift data for the presence states of
contacts. The data which is being read has some optional fields, which
are rarely not supplied. This has led to this bug being undiscovered
for quite some time.
Not only was the plugin not properly accounting for optional fields,
but also did not account for field scoping. This is not really an issue
until a Thrift list is being read, which will cause the identifier to
grow with each field read, rather than reset. The field identifier is
only relevant to its local scope, nothing more. More importantly, the
identifier must be reset with each iteration of a list.
Diffstat (limited to 'facebook/facebook-api.h')
-rw-r--r-- | facebook/facebook-api.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/facebook/facebook-api.h b/facebook/facebook-api.h index 15e4cb2..757de9d 100644 --- a/facebook/facebook-api.h +++ b/facebook/facebook-api.h @@ -190,6 +190,30 @@ #define FB_API_CONTACTS_COUNT 500 /** + * FB_API_TCHK: + * @e: The expression. + * + * Checks the Thrift related expression to ensure that it evaluates to + * #TRUE. If the expression evaluates to #FALSE, a #GError is assigned + * to the local `error` variable, then returns with no value. + * + * This macro is meant to only be used for Thrift related expressions, + * where the calling function has a `void` return type. This macro also + * requires the existence of a predefined `error` variable, which is a + * pointer of a pointer to a #GError. + */ +#define FB_API_TCHK(e) \ + G_STMT_START { \ + if (G_UNLIKELY(!(e))) { \ + g_set_error(error, FB_API_ERROR, FB_API_ERROR_GENERAL, \ + "Failed to read thrift: %s:%d " \ + "%s: assertion '%s' failed", \ + __FILE__, __LINE__, G_STRFUNC, #e); \ + return; \ + } \ + } G_STMT_END + +/** * FB_API_MSGID: * @m: The time in milliseconds. * @i: The random integer. |