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

James Geboski <[email protected]>
Newsgroups gmane.comp.gnome.gaim.cvs
Message-ID <[email protected]>
Changeset: 358b11b0a793f5538583d8f5b3b68e75332965b9
Author:	 James Geboski <[email protected]>
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);
 	}
 

_______________________________________________
Commits mailing list
[email protected]
https://pidgin.im/cgi-bin/mailman/listinfo/commits
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.