[libsocialweb] myspace-item-view: Fix potential corruption bug by changing owner unowned string
- From: Rob Bradford <rbradford src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsocialweb] myspace-item-view: Fix potential corruption bug by changing owner unowned string
- Date: Fri, 29 Apr 2011 16:59:02 +0000 (UTC)
commit 46c09ff2ad212b38239074d9b6e681645d5708a4
Author: Rob Bradford <rob linux intel com>
Date: Fri Apr 29 17:00:44 2011 +0100
myspace-item-view: Fix potential corruption bug by changing owner unowned string
The string returned by json_object_get_string_member is owned by the
JsonObject - it's pretty rude to use sw_unescape_entities on it to change it's
content.
It's even worse to give the ownership using sw_item_take when you don't own it
the first place.
services/myspace/myspace-item-view.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/services/myspace/myspace-item-view.c b/services/myspace/myspace-item-view.c
index 25797a5..0c51a7e 100644
--- a/services/myspace/myspace-item-view.c
+++ b/services/myspace/myspace-item-view.c
@@ -221,7 +221,6 @@ make_item (SwService *service, JsonNode *entry)
JsonNode *author;
JsonObject *entry_obj, *author_obj;
const char *tmp;
- char *status;
item = sw_item_new ();
sw_item_set_service (item, service);
@@ -257,8 +256,9 @@ make_item (SwService *service, JsonNode *entry)
sw_item_request_image_fetch (item, FALSE, "authoricon", g_strdup (tmp));;
/* Get the content */
- status = json_object_get_string_member (entry_obj, "status");
- sw_item_put (item, "content", sw_unescape_entities ((gchar *)status));
+ tmp = json_object_get_string_member (entry_obj, "status");
+ /* sw_unescape_entities works in place -> must duplicate before */
+ sw_item_take (item, "content", sw_unescape_entities (g_strdup (tmp)));
/* TODO: if mood is not "(none)" then append that to the status message */
/* Get the date */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]