soc.2010.icq-tlc: 92760ff5: Bstream cleanups:

ivan.komarov at soc.pidgin.im ivan.komarov at soc.pidgin.im
Wed Jul 28 20:00:59 EDT 2010


----------------------------------------------------------------------
Revision: 92760ff5074d9bcc75f59473f013ca8a959a85b8
Parent:   542307fd29430cf230d204d0375529f84786590b
Author:   ivan.komarov at soc.pidgin.im
Date:     07/28/10 19:53:25
Branch:   im.pidgin.soc.2010.icq-tlc
URL: http://d.pidgin.im/viewmtn/revision/info/92760ff5074d9bcc75f59473f013ca8a959a85b8

Changelog: 

Bstream cleanups:
  1. g_return_val_if_fail()'s in place of XXX's.
  2. byte_stream_empty() -> byte_stream_bytes_left(). I think the world
     is a better place now.

Changes against parent 542307fd29430cf230d204d0375529f84786590b

  patched  libpurple/protocols/oscar/bstream.c
  patched  libpurple/protocols/oscar/family_admin.c
  patched  libpurple/protocols/oscar/family_chat.c
  patched  libpurple/protocols/oscar/family_feedbag.c
  patched  libpurple/protocols/oscar/family_icbm.c
  patched  libpurple/protocols/oscar/family_locate.c
  patched  libpurple/protocols/oscar/family_oservice.c
  patched  libpurple/protocols/oscar/flap_connection.c
  patched  libpurple/protocols/oscar/misc.c
  patched  libpurple/protocols/oscar/oscar.h
  patched  libpurple/protocols/oscar/peer_proxy.c
  patched  libpurple/protocols/oscar/tlv.c

-------------- next part --------------
============================================================
--- libpurple/protocols/oscar/misc.c	6dd76b0b4674201098e8f305b08b9c2deb51c76e
+++ libpurple/protocols/oscar/misc.c	e78998d518909de21a47a486f4493f8a61f8d901
@@ -91,7 +91,7 @@ generror(OscarData *od, FlapConnection *
 
 	snac2 = aim_remsnac(od, snac->id);
 
-	if (byte_stream_empty(bs))
+	if (byte_stream_bytes_left(bs))
 		error = byte_stream_get16(bs);
 
 	if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
============================================================
--- libpurple/protocols/oscar/tlv.c	3b758fa77fa9e2f1cb6aa61dc4f246e4af7203be
+++ libpurple/protocols/oscar/tlv.c	f66244270958c60cdf9bad0660edad4a2eb98141
@@ -49,7 +49,7 @@ aim_tlv_read(GSList *list, ByteStream *b
 	type = byte_stream_get16(bs);
 	length = byte_stream_get16(bs);
 
-	if (length > byte_stream_empty(bs)) {
+	if (length > byte_stream_bytes_left(bs)) {
 		aim_tlvlist_free(list);
 		return NULL;
 	}
@@ -88,7 +88,7 @@ GSList *aim_tlvlist_read(ByteStream *bs)
 {
 	GSList *list = NULL;
 
-	while (byte_stream_empty(bs) > 0) {
+	while (byte_stream_bytes_left(bs) > 0) {
 		list = aim_tlv_read(list, bs);
 		if (list == NULL)
 			return NULL;
@@ -122,7 +122,7 @@ GSList *aim_tlvlist_readnum(ByteStream *
 {
 	GSList *list = NULL;
 
-	while ((byte_stream_empty(bs) > 0) && (num != 0)) {
+	while ((byte_stream_bytes_left(bs) > 0) && (num != 0)) {
 		list = aim_tlv_read(list, bs);
 		if (list == NULL)
 			return NULL;
@@ -157,7 +157,7 @@ GSList *aim_tlvlist_readlen(ByteStream *
 {
 	GSList *list = NULL;
 
-	while ((byte_stream_empty(bs) > 0) && (len > 0)) {
+	while ((byte_stream_bytes_left(bs) > 0) && (len > 0)) {
 		list = aim_tlv_read(list, bs);
 		if (list == NULL)
 			return NULL;
@@ -648,7 +648,7 @@ int aim_tlvlist_write(ByteStream *bs, GS
 	/* do an initial run to test total length */
 	goodbuflen = aim_tlvlist_size(*list);
 
-	if (goodbuflen > byte_stream_empty(bs))
+	if (goodbuflen > byte_stream_bytes_left(bs))
 		return 0; /* not enough buffer */
 
 	/* do the real write-out */
============================================================
--- libpurple/protocols/oscar/bstream.c	3fa6dd1e0661576aae2c20be5e28a600365a80dd
+++ libpurple/protocols/oscar/bstream.c	296d6ffef0d2491187928c1da11ba145c0bc96fa
@@ -34,7 +34,6 @@ int byte_stream_init(ByteStream *bs, gui
 
 int byte_stream_init(ByteStream *bs, guint8 *data, int len)
 {
-
 	if (bs == NULL)
 		return -1;
 
@@ -50,7 +49,7 @@ void byte_stream_destroy(ByteStream *bs)
 	g_free(bs->data);
 }
 
-int byte_stream_empty(ByteStream *bs)
+int byte_stream_bytes_left(ByteStream *bs)
 {
 	return bs->len - bs->offset;
 }
@@ -62,102 +61,74 @@ int byte_stream_setpos(ByteStream *bs, u
 
 int byte_stream_setpos(ByteStream *bs, unsigned int off)
 {
+	g_return_val_if_fail(off <= bs->len, -1);
 
-	if (off > bs->len)
-		return -1;
-
 	bs->offset = off;
-
 	return off;
 }
 
 void byte_stream_rewind(ByteStream *bs)
 {
-
 	byte_stream_setpos(bs, 0);
-
-	return;
 }
 
 /*
  * N can be negative, which can be used for going backwards
- * in a bstream.  I'm not sure if libfaim actually does
- * this anywhere...
+ * in a bstream.
  */
 int byte_stream_advance(ByteStream *bs, int n)
 {
+	g_return_val_if_fail((byte_stream_curpos(bs) + n >= 0) && (n <= byte_stream_bytes_left(bs)), 0);
 
-	if ((byte_stream_curpos(bs) + n < 0) || (byte_stream_empty(bs) < n))
-		return 0; /* XXX throw an exception */
-
 	bs->offset += n;
-
 	return n;
 }
 
 guint8 byte_stream_get8(ByteStream *bs)
 {
+	g_return_val_if_fail(byte_stream_bytes_left(bs) >= 1, 0);
 
-	if (byte_stream_empty(bs) < 1)
-		return 0; /* XXX throw an exception */
-
 	bs->offset++;
-
 	return aimutil_get8(bs->data + bs->offset - 1);
 }
 
 guint16 byte_stream_get16(ByteStream *bs)
 {
+	g_return_val_if_fail(byte_stream_bytes_left(bs) >= 2, 0);
 
-	if (byte_stream_empty(bs) < 2)
-		return 0; /* XXX throw an exception */
-
 	bs->offset += 2;
-
 	return aimutil_get16(bs->data + bs->offset - 2);
 }
 
 guint32 byte_stream_get32(ByteStream *bs)
 {
+	g_return_val_if_fail(byte_stream_bytes_left(bs) >= 4, 0);
 
-	if (byte_stream_empty(bs) < 4)
-		return 0; /* XXX throw an exception */
-
 	bs->offset += 4;
-
 	return aimutil_get32(bs->data + bs->offset - 4);
 }
 
 guint8 byte_stream_getle8(ByteStream *bs)
 {
+	g_return_val_if_fail(byte_stream_bytes_left(bs) >= 1, 0);
 
-	if (byte_stream_empty(bs) < 1)
-		return 0; /* XXX throw an exception */
-
 	bs->offset++;
-
 	return aimutil_getle8(bs->data + bs->offset - 1);
 }
 
 guint16 byte_stream_getle16(ByteStream *bs)
 {
+	g_return_val_if_fail(byte_stream_bytes_left(bs) >= 2, 0);
 
-	if (byte_stream_empty(bs) < 2)
-		return 0; /* XXX throw an exception */
-
 	bs->offset += 2;
-
 	return aimutil_getle16(bs->data + bs->offset - 2);
 }
 
 guint32 byte_stream_getle32(ByteStream *bs)
 {
+	g_return_val_if_fail(byte_stream_bytes_left(bs) >= 4, 0);
 
-	if (byte_stream_empty(bs) < 4)
-		return 0; /* XXX throw an exception */
-
 	bs->offset += 4;
-
 	return aimutil_getle32(bs->data + bs->offset - 4);
 }
 
@@ -169,10 +140,8 @@ int byte_stream_getrawbuf(ByteStream *bs
 
 int byte_stream_getrawbuf(ByteStream *bs, guint8 *buf, int len)
 {
+	g_return_val_if_fail(byte_stream_bytes_left(bs) >= len, 0);
 
-	if (byte_stream_empty(bs) < len)
-		return 0;
-
 	byte_stream_getrawbuf_nocheck(bs, buf, len);
 	return len;
 }
@@ -181,13 +150,10 @@ guint8 *byte_stream_getraw(ByteStream *b
 {
 	guint8 *ob;
 
-	if (byte_stream_empty(bs) < len)
-		return NULL;
+	g_return_val_if_fail(byte_stream_bytes_left(bs) >= len, NULL);
 
 	ob = g_malloc(len);
-
 	byte_stream_getrawbuf_nocheck(bs, ob, len);
-
 	return ob;
 }
 
@@ -195,94 +161,69 @@ char *byte_stream_getstr(ByteStream *bs,
 {
 	char *ob;
 
-	if (byte_stream_empty(bs) < len)
-		return NULL;
+	g_return_val_if_fail(byte_stream_bytes_left(bs) >= len, NULL);
 
 	ob = g_malloc(len + 1);
-
 	byte_stream_getrawbuf_nocheck(bs, (guint8 *)ob, len);
-
 	ob[len] = '\0';
-
 	return ob;
 }
 
 int byte_stream_put8(ByteStream *bs, guint8 v)
 {
+	g_return_val_if_fail(byte_stream_bytes_left(bs) >= 1, 0);
 
-	if (byte_stream_empty(bs) < 1)
-		return 0; /* XXX throw an exception */
-
 	bs->offset += aimutil_put8(bs->data + bs->offset, v);
-
 	return 1;
 }
 
 int byte_stream_put16(ByteStream *bs, guint16 v)
 {
+	g_return_val_if_fail(byte_stream_bytes_left(bs) >= 2, 0);
 
-	if (byte_stream_empty(bs) < 2)
-		return 0; /* XXX throw an exception */
-
 	bs->offset += aimutil_put16(bs->data + bs->offset, v);
-
 	return 2;
 }
 
 int byte_stream_put32(ByteStream *bs, guint32 v)
 {
+	g_return_val_if_fail(byte_stream_bytes_left(bs) >= 4, 0);
 
-	if (byte_stream_empty(bs) < 4)
-		return 0; /* XXX throw an exception */
-
 	bs->offset += aimutil_put32(bs->data + bs->offset, v);
-
 	return 1;
 }
 
 int byte_stream_putle8(ByteStream *bs, guint8 v)
 {
+	g_return_val_if_fail(byte_stream_bytes_left(bs) >= 1, 0);
 
-	if (byte_stream_empty(bs) < 1)
-		return 0; /* XXX throw an exception */
-
 	bs->offset += aimutil_putle8(bs->data + bs->offset, v);
-
 	return 1;
 }
 
 int byte_stream_putle16(ByteStream *bs, guint16 v)
 {
+	g_return_val_if_fail(byte_stream_bytes_left(bs) >= 2, 0);
 
-	if (byte_stream_empty(bs) < 2)
-		return 0; /* XXX throw an exception */
-
 	bs->offset += aimutil_putle16(bs->data + bs->offset, v);
-
 	return 2;
 }
 
 int byte_stream_putle32(ByteStream *bs, guint32 v)
 {
+	g_return_val_if_fail(byte_stream_bytes_left(bs) >= 4, 0);
 
-	if (byte_stream_empty(bs) < 4)
-		return 0; /* XXX throw an exception */
-
 	bs->offset += aimutil_putle32(bs->data + bs->offset, v);
-
 	return 1;
 }
 
 
 int byte_stream_putraw(ByteStream *bs, const guint8 *v, int len)
 {
+	g_return_val_if_fail(byte_stream_bytes_left(bs) >= len, 0);
 
-	if (byte_stream_empty(bs) < len)
-		return 0; /* XXX throw an exception */
-
 	memcpy(bs->data + bs->offset, v, len);
 	bs->offset += len;
-
 	return len;
 }
 
@@ -293,17 +234,12 @@ int byte_stream_putbs(ByteStream *bs, By
 
 int byte_stream_putbs(ByteStream *bs, ByteStream *srcbs, int len)
 {
+	g_return_val_if_fail(byte_stream_bytes_left(srcbs) >= len, 0);
+	g_return_val_if_fail(byte_stream_bytes_left(bs) >= len, 0);
 
-	if (byte_stream_empty(srcbs) < len)
-		return 0; /* XXX throw exception (underrun) */
-
-	if (byte_stream_empty(bs) < len)
-		return 0; /* XXX throw exception (overflow) */
-
 	memcpy(bs->data + bs->offset, srcbs->data + srcbs->offset, len);
 	bs->offset += len;
 	srcbs->offset += len;
-
 	return len;
 }
 
============================================================
--- libpurple/protocols/oscar/family_admin.c	d507e141cf3930047f5191ba9b34de13e9f670a4
+++ libpurple/protocols/oscar/family_admin.c	8ddd46927e5ef2df0826d4cdebc4cd960c6547fc
@@ -68,7 +68,7 @@ infochange(OscarData *od, FlapConnection
 	perms = byte_stream_get16(bs);
 	tlvcount = byte_stream_get16(bs);
 
-	while (tlvcount && byte_stream_empty(bs)) {
+	while (tlvcount && byte_stream_bytes_left(bs)) {
 		guint16 type, length;
 
 		type = byte_stream_get16(bs);
============================================================
--- libpurple/protocols/oscar/family_chat.c	2faf894f7457faf6d6e0ffa8a5bf5b07455412ed
+++ libpurple/protocols/oscar/family_chat.c	23fa73a3bad22eab00f943158e83fb9c72572171
@@ -122,7 +122,7 @@ userlistchange(OscarData *od, FlapConnec
 	aim_rxcallback_t userfunc;
 	int curcount = 0, ret = 0;
 
-	while (byte_stream_empty(bs)) {
+	while (byte_stream_bytes_left(bs)) {
 		curcount++;
 		userinfo = g_realloc(userinfo, curcount * sizeof(aim_userinfo_t));
 		aim_info_extract(od, bs, &userinfo[curcount-1]);
============================================================
--- libpurple/protocols/oscar/family_feedbag.c	feacad30372ce3f45979e391518cd7c49c130d56
+++ libpurple/protocols/oscar/family_feedbag.c	f4cffed61f4375f57e8b87f98d34dcf47a122d33
@@ -1170,7 +1170,7 @@ static int parsedata(OscarData *od, Flap
 	od->ssi.numitems += byte_stream_get16(bs); /* # of items in this SSI SNAC */
 
 	/* Read in the list */
-	while (byte_stream_empty(bs) > 4) { /* last four bytes are timestamp */
+	while (byte_stream_bytes_left(bs) > 4) { /* last four bytes are timestamp */
 		if ((namelen = byte_stream_get16(bs)))
 			name = byte_stream_getstr(bs, namelen);
 		else
@@ -1288,7 +1288,7 @@ static int parseadd(OscarData *od, FlapC
 	guint16 len, gid, bid, type;
 	GSList *data;
 
-	while (byte_stream_empty(bs)) {
+	while (byte_stream_bytes_left(bs)) {
 		if ((len = byte_stream_get16(bs)))
 			name = byte_stream_getstr(bs, len);
 		else
@@ -1326,7 +1326,7 @@ static int parsemod(OscarData *od, FlapC
 	GSList *data;
 	struct aim_ssi_item *item;
 
-	while (byte_stream_empty(bs)) {
+	while (byte_stream_bytes_left(bs)) {
 		if ((len = byte_stream_get16(bs)))
 			name = byte_stream_getstr(bs, len);
 		else
@@ -1378,7 +1378,7 @@ static int parsedel(OscarData *od, FlapC
 	guint16 gid, bid;
 	struct aim_ssi_item *del;
 
-	while (byte_stream_empty(bs)) {
+	while (byte_stream_bytes_left(bs)) {
 		byte_stream_advance(bs, byte_stream_get16(bs));
 		gid = byte_stream_get16(bs);
 		bid = byte_stream_get16(bs);
@@ -1411,7 +1411,7 @@ static int parseack(OscarData *od, FlapC
 
 	/* Read in the success/failure flags from the ack SNAC */
 	cur = od->ssi.pending;
-	while (cur && (byte_stream_empty(bs)>0)) {
+	while (cur && (byte_stream_bytes_left(bs)>0)) {
 		cur->ack = byte_stream_get16(bs);
 		cur = cur->next;
 	}
============================================================
--- libpurple/protocols/oscar/family_icbm.c	59750b5578ffaca64076fe45e65864e441c78351
+++ libpurple/protocols/oscar/family_icbm.c	aaf47da89a215134abe6392f5fb853f7f5971f14
@@ -919,7 +919,7 @@ incomingim_ch1_parsemsg(OscarData *od, a
 	/*
 	 * We're interested in the inner TLV 0x101, which contains precious, precious message.
 	 */
-	while (byte_stream_empty(message) >= 4) {
+	while (byte_stream_bytes_left(message) >= 4) {
 		guint16 type = byte_stream_get16(message);
 		guint16 length = byte_stream_get16(message);
 		if (type == 0x101) {
@@ -952,12 +952,12 @@ incomingim_ch1(OscarData *od, FlapConnec
 	 * I've changed it to process the TLVs in-place.  This avoids lots
 	 * of per-IM memory allocations.
 	 */
-	while (byte_stream_empty(bs) >= 4)
+	while (byte_stream_bytes_left(bs) >= 4)
 	{
 		type = byte_stream_get16(bs);
 		length = byte_stream_get16(bs);
 
-		if (length > byte_stream_empty(bs))
+		if (length > byte_stream_bytes_left(bs))
 		{
 			purple_debug_misc("oscar", "Received an IM containing an invalid message part from %s.  They are probably trying to do something malicious.\n", userinfo->bn);
 			break;
@@ -1050,7 +1050,7 @@ incomingim_ch2_buddylist(OscarData *od, 
 	 *     ...
 	 *   ...
 	 */
-	while (byte_stream_empty(servdata))
+	while (byte_stream_bytes_left(servdata))
 	{
 		guint16 gnlen, numb;
 		int i;
@@ -1550,7 +1550,7 @@ static int missedcall(OscarData *od, Fla
 	guint16 channel, nummissed, reason;
 	aim_userinfo_t userinfo;
 
-	while (byte_stream_empty(bs)) {
+	while (byte_stream_bytes_left(bs)) {
 
 		channel = byte_stream_get16(bs);
 		aim_info_extract(od, bs, &userinfo);
============================================================
--- libpurple/protocols/oscar/family_locate.c	e87b992e46d0c9942e98be243c3df09d5d1c5447
+++ libpurple/protocols/oscar/family_locate.c	cc15ed02531cd01818b72913ee3facbca6f4cfc3
@@ -583,7 +583,7 @@ aim_locate_getcaps(OscarData *od, ByteSt
 	guint64 flags = 0;
 	int offset;
 
-	for (offset = 0; byte_stream_empty(bs) && (offset < len); offset += 0x10) {
+	for (offset = 0; byte_stream_bytes_left(bs) && (offset < len); offset += 0x10) {
 		guint8 *cap;
 		int i, identified;
 
@@ -617,7 +617,7 @@ aim_receive_custom_icon(OscarData *od, B
 	int offset;
 	const char *result = NULL;
 
-	for (offset = 0; byte_stream_empty(bs) && (offset < len); offset += 0x10) {
+	for (offset = 0; byte_stream_bytes_left(bs) && (offset < len); offset += 0x10) {
 		/* check wheather this capability is a custom user icon */
 		guint8 *cap;
 		int i;
@@ -643,7 +643,7 @@ aim_locate_getcaps_short(OscarData *od, 
 	guint64 flags = 0;
 	int offset;
 
-	for (offset = 0; byte_stream_empty(bs) && (offset < len); offset += 0x02) {
+	for (offset = 0; byte_stream_bytes_left(bs) && (offset < len); offset += 0x02) {
 		guint8 *cap;
 		int i, identified;
 
@@ -674,7 +674,7 @@ byte_stream_putcaps(ByteStream *bs, guin
 	if (!bs)
 		return -EINVAL;
 
-	for (i = 0; byte_stream_empty(bs); i++) {
+	for (i = 0; byte_stream_bytes_left(bs); i++) {
 
 		if (aim_caps[i].flag == OSCAR_CAPABILITY_LAST)
 			break;
@@ -804,7 +804,7 @@ aim_info_extract(OscarData *od, ByteStre
 		type = byte_stream_get16(bs);
 		length = byte_stream_get16(bs);
 		curpos = byte_stream_curpos(bs);
-		endpos = curpos + MIN(length, byte_stream_empty(bs));
+		endpos = curpos + MIN(length, byte_stream_bytes_left(bs));
 
 		if (type == 0x0001) {
 			/*
@@ -1010,7 +1010,7 @@ aim_info_extract(OscarData *od, ByteStre
 				number2 = byte_stream_get8(bs);
 				length2 = byte_stream_get8(bs);
 
-				endpos2 = byte_stream_curpos(bs) + MIN(length2, byte_stream_empty(bs));
+				endpos2 = byte_stream_curpos(bs) + MIN(length2, byte_stream_bytes_left(bs));
 
 				switch (type2) {
 					case 0x0000: { /* This is an official buddy icon? */
============================================================
--- libpurple/protocols/oscar/family_oservice.c	d7f64a85d625b9a982c7f8cb8bb611a00ee11cd7
+++ libpurple/protocols/oscar/family_oservice.c	d8cebf16f627dbe4853b3284fc30abecb619eac2
@@ -97,7 +97,7 @@ hostonline(OscarData *od, FlapConnection
 {
 	int group;
 
-	while (byte_stream_empty(bs))
+	while (byte_stream_bytes_left(bs))
 	{
 		group = byte_stream_get16(bs);
 		conn->groups = g_slist_prepend(conn->groups, GUINT_TO_POINTER(group));
@@ -586,7 +586,7 @@ evilnotify(OscarData *od, FlapConnection
 
 	newevil = byte_stream_get16(bs);
 
-	if (byte_stream_empty(bs))
+	if (byte_stream_bytes_left(bs))
 		aim_info_extract(od, bs, &userinfo);
 
 	if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
@@ -763,8 +763,8 @@ hostversions(OscarData *od, FlapConnecti
 	guint8 *versions;
 
 	/* This is frivolous. (Thank you SmarterChild.) */
-	vercount = byte_stream_empty(bs)/4;
-	versions = byte_stream_getraw(bs, byte_stream_empty(bs));
+	vercount = byte_stream_bytes_left(bs)/4;
+	versions = byte_stream_getraw(bs, byte_stream_bytes_left(bs));
 	g_free(versions);
 
 	/*
============================================================
--- libpurple/protocols/oscar/oscar.h	879ddfe2fd440fbf46f088989f8fa9f087110841
+++ libpurple/protocols/oscar/oscar.h	1fb992c3ca6d7d0d1e196ff621fcc63234e06c35
@@ -1209,7 +1209,7 @@ void byte_stream_destroy(ByteStream *bs)
 int byte_stream_new(ByteStream *bs, guint32 len);
 int byte_stream_init(ByteStream *bs, guint8 *data, int len);
 void byte_stream_destroy(ByteStream *bs);
-int byte_stream_empty(ByteStream *bs);
+int byte_stream_bytes_left(ByteStream *bs);
 int byte_stream_curpos(ByteStream *bs);
 int byte_stream_setpos(ByteStream *bs, unsigned int off);
 void byte_stream_rewind(ByteStream *bs);
============================================================
--- libpurple/protocols/oscar/flap_connection.c	712a6a3fd36aeee991a1d1b61656d12c9d80062b
+++ libpurple/protocols/oscar/flap_connection.c	4f6eee6c2f40a240e549a2a2d19f559eb48ab379
@@ -733,7 +733,7 @@ parse_snac(OscarData *od, FlapConnection
 	aim_module_t *cur;
 	aim_modsnac_t snac;
 
-	if (byte_stream_empty(&frame->data) < 10)
+	if (byte_stream_bytes_left(&frame->data) < 10)
 		return;
 
 	snac.family = byte_stream_get16(&frame->data);
@@ -800,7 +800,7 @@ parse_flap_ch4(OscarData *od, FlapConnec
 	GSList *tlvlist;
 	char *msg = NULL;
 
-	if (byte_stream_empty(&frame->data) == 0) {
+	if (byte_stream_bytes_left(&frame->data) == 0) {
 		/* XXX should do something with this */
 		return;
 	}
@@ -1062,8 +1062,8 @@ flap_connection_send_byte_stream(ByteStr
 		return;
 
 	/* Make sure we don't send past the end of the bs */
-	if (count > byte_stream_empty(bs))
-		count = byte_stream_empty(bs); /* truncate to remaining space */
+	if (count > byte_stream_bytes_left(bs))
+		count = byte_stream_bytes_left(bs); /* truncate to remaining space */
 
 	if (count == 0)
 		return;
============================================================
--- libpurple/protocols/oscar/peer_proxy.c	45a63bd0247c4a227d7c9cc18198ae42f59ad727
+++ libpurple/protocols/oscar/peer_proxy.c	2849544369245997d353958e101de7782b673f5f
@@ -168,7 +168,7 @@ peer_proxy_recv_frame(PeerConnection *co
 	}
 	else if (frame->type == PEER_PROXY_TYPE_ERROR)
 	{
-		if (byte_stream_empty(&frame->payload) >= 2)
+		if (byte_stream_bytes_left(&frame->payload) >= 2)
 		{
 			guint16 error;
 			const char *msg;


More information about the Commits mailing list