/soc/2015/jgeboski/facebook: 358b11b0a793: facebook: fixed parsi...

James Geboski jgeboski at gmail.com
Mon Jul 6 18:06:32 EDT 2015


Changeset: 358b11b0a793f5538583d8f5b3b68e75332965b9
Author:	 James Geboski <jgeboski at gmail.com>
Date:	 2015-07-06 18:04 -0400
Branch:	 facebook
URL: https://hg.pidgin.im/soc/2015/jgeboski/facebook/rev/358b11b0a793

Description:

facebook: fixed parsing of empty JSON data

diffstat:

 libpurple/protocols/facebook/api.c |  8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diffs (25 lines):

diff --git a/libpurple/protocols/facebook/api.c b/libpurple/protocols/facebook/api.c
--- a/libpurple/protocols/facebook/api.c
+++ b/libpurple/protocols/facebook/api.c
@@ -312,6 +312,12 @@ fb_api_json_chk(FbApi *api, gconstpointe
 	g_return_val_if_fail(FB_IS_API(api), FALSE);
 	priv = api->priv;
 
+	if (G_UNLIKELY(size == 0)) {
+		g_set_error(&err, FB_API_ERROR, FB_API_ERROR_GENERAL,
+		            _("Invalid JSON data"));
+		FB_API_ERROR_CHK(api, err, return FALSE);
+	}
+
 	fb_util_debug(FB_UTIL_DEBUG_INFO, "Parsing JSON: %.*s",
 	              (gint) size, (const gchar *) data);
 
@@ -356,7 +362,7 @@ fb_api_http_chk(FbApi *api, PurpleHttpRe
 	GError *err = NULL;
 	gsize size;
 
-	if ((res != NULL) && !fb_http_error_chk(res, &err)) {
+	if (!fb_http_error_chk(res, &err)) {
 		FB_API_ERROR_CHK(api, err, return FALSE);
 	}
 



More information about the Commits mailing list