libpurple/protocols/zephyr/Zinternal.c

changeset 40756
3a58ef28ee44
parent 40653
503cfa50c8c3
equal deleted inserted replaced
40754:aef08fe14d13 40756:3a58ef28ee44
8 * For copying and distribution information, see the file 8 * For copying and distribution information, see the file
9 * "mit-copyright.h". 9 * "mit-copyright.h".
10 */ 10 */
11 11
12 #include <purple.h> 12 #include <purple.h>
13 #include "libpurple/glibcompat.h"
13 14
14 #include "internal.h" 15 #include "internal.h"
15 #ifdef WIN32 16 #ifdef WIN32
16 #include <winsock2.h> 17 #include <winsock2.h>
17 #else 18 #else
330 if ((qptr = Z_SearchQueue(&notice.z_multiuid, notice.z_kind)) != NULL) { 331 if ((qptr = Z_SearchQueue(&notice.z_multiuid, notice.z_kind)) != NULL) {
331 /* If this is the first fragment, and we haven't already gotten 332 /* If this is the first fragment, and we haven't already gotten
332 * a first fragment, grab the header from it. */ 333 * a first fragment, grab the header from it. */
333 if (part == 0 && qptr->header == NULL) { 334 if (part == 0 && qptr->header == NULL) {
334 qptr->header_len = packet_len - notice.z_message_len; 335 qptr->header_len = packet_len - notice.z_message_len;
335 qptr->header = g_memdup(packet, qptr->header_len); 336 qptr->header = g_memdup2(packet, qptr->header_len);
336 } 337 }
337 g_object_unref(from); 338 g_object_unref(from);
338 return Z_AddNoticeToEntry(qptr, &notice, part); 339 return Z_AddNoticeToEntry(qptr, &notice, part);
339 } 340 }
340 } 341 }
362 /* If this is the first part of the notice, we take the header from it. 363 /* If this is the first part of the notice, we take the header from it.
363 * We only take it if this is the first fragment so that the Unique 364 * We only take it if this is the first fragment so that the Unique
364 * ID's will be predictable. */ 365 * ID's will be predictable. */
365 if (part == 0) { 366 if (part == 0) {
366 qptr->header_len = packet_len - notice.z_message_len; 367 qptr->header_len = packet_len - notice.z_message_len;
367 qptr->header = g_memdup(packet, qptr->header_len); 368 qptr->header = g_memdup2(packet, qptr->header_len);
368 } 369 }
369 370
370 /* If this is not a fragmented notice, then don't bother with a hole 371 /* If this is not a fragmented notice, then don't bother with a hole
371 * list. */ 372 * list. */
372 if (part == 0 && notice.z_message_len == partof) { 373 if (part == 0 && notice.z_message_len == partof) {
375 qptr->complete = TRUE; 376 qptr->complete = TRUE;
376 /* allocate a msg buf for this piece */ 377 /* allocate a msg buf for this piece */
377 if (notice.z_message_len == 0) { 378 if (notice.z_message_len == 0) {
378 qptr->msg = NULL; 379 qptr->msg = NULL;
379 } else { 380 } else {
380 qptr->msg = g_memdup(notice.z_message, notice.z_message_len); 381 qptr->msg = g_memdup2(notice.z_message, notice.z_message_len);
381 } 382 }
382 qptr->msg_len = notice.z_message_len; 383 qptr->msg_len = notice.z_message_len;
383 __Q_Size += notice.z_message_len; 384 __Q_Size += notice.z_message_len;
384 qptr->packet_len = qptr->header_len + qptr->msg_len; 385 qptr->packet_len = qptr->header_len + qptr->msg_len;
385 qptr->packet = g_new(gchar, qptr->packet_len); 386 qptr->packet = g_new(gchar, qptr->packet_len);

mercurial