comparison libpurple/protocols/msn/slp.c @ 29211:091797665df5

There's no need to check type twice here. Also, g_return_if_reached is not correct since img==NULL is caused by invalid network input and not some programmer error.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Thu, 31 Dec 2009 04:13:55 +0000
parents 139aa186e8cc
children d3298d8f67dd
comparison
equal deleted inserted replaced
29210:0b48f58e8c50 29211:091797665df5
291 gsize len; 291 gsize len;
292 MsnSlpLink *slplink; 292 MsnSlpLink *slplink;
293 MsnSlpMessage *slpmsg; 293 MsnSlpMessage *slpmsg;
294 MsnObject *obj; 294 MsnObject *obj;
295 char *msnobj_data; 295 char *msnobj_data;
296 PurpleStoredImage *img; 296 PurpleStoredImage *img = NULL;
297 int type; 297 int type;
298 298
299 /* Send Ok */ 299 /* Send Ok */
300 content = g_strdup_printf("SessionID: %lu\r\n\r\n", 300 content = g_strdup_printf("SessionID: %lu\r\n\r\n",
301 slpcall->session_id); 301 slpcall->session_id);
309 309
310 msnobj_data = (char *)purple_base64_decode(context, &len); 310 msnobj_data = (char *)purple_base64_decode(context, &len);
311 obj = msn_object_new_from_string(msnobj_data); 311 obj = msn_object_new_from_string(msnobj_data);
312 type = msn_object_get_type(obj); 312 type = msn_object_get_type(obj);
313 g_free(msnobj_data); 313 g_free(msnobj_data);
314
315 if ((type != MSN_OBJECT_USERTILE) && (type != MSN_OBJECT_EMOTICON))
316 {
317 purple_debug_error("msn", "Wrong object?\n");
318 msn_object_destroy(obj);
319 g_return_if_reached();
320 }
321 314
322 if (type == MSN_OBJECT_EMOTICON) { 315 if (type == MSN_OBJECT_EMOTICON) {
323 char *path; 316 char *path;
324 path = g_build_filename(purple_smileys_get_storing_dir(), 317 path = g_build_filename(purple_smileys_get_storing_dir(),
325 obj->location, NULL); 318 obj->location, NULL);
326 img = purple_imgstore_new_from_file(path); 319 img = purple_imgstore_new_from_file(path);
327 g_free(path); 320 g_free(path);
328 } else { 321 } else if (type == MSN_OBJECT_USERTILE) {
329 img = msn_object_get_image(obj); 322 img = msn_object_get_image(obj);
330 if (img) 323 if (img)
331 purple_imgstore_ref(img); 324 purple_imgstore_ref(img);
332 } 325 }
333 msn_object_destroy(obj); 326 msn_object_destroy(obj);
334 327
335 if (img == NULL) 328 if (img == NULL)
336 { 329 {
337 purple_debug_error("msn", "Wrong object.\n"); 330 purple_debug_error("msn", "Wrong object.\n");
338 g_return_if_reached(); 331 return;
339 } 332 }
340 333
341 /* DATA PREP */ 334 /* DATA PREP */
342 slpmsg = msn_slpmsg_new(slplink); 335 slpmsg = msn_slpmsg_new(slplink);
343 slpmsg->slpcall = slpcall; 336 slpmsg->slpcall = slpcall;