libpurple/protocols/mxit/chunk.c

branch
soc.2013.gobjectification.plugins
changeset 37131
fe9ff76f1c6c
parent 36858
920cf8db7c68
parent 35680
965839bfe169
child 37133
832cd077145e
--- a/libpurple/protocols/mxit/chunk.c	Thu Apr 03 08:06:11 2014 +0530
+++ b/libpurple/protocols/mxit/chunk.c	Thu Apr 03 09:31:58 2014 +0530
@@ -170,9 +170,13 @@
  */
 static int get_int16( const char* chunkdata, short* value )
 {
-	*value = ntohs( *( (const short*) chunkdata ) );	/* host byte-order */
+	gint16 value_v;
+
+	memcpy(&value_v, chunkdata, sizeof(value_v));
 
-	return sizeof( short );
+	*value = ntohs(value_v); /* host byte-order */
+
+	return sizeof(value_v);
 }
 
 /*------------------------------------------------------------------------
@@ -184,9 +188,13 @@
  */
 static int get_int32( const char* chunkdata, int* value )
 {
-	*value = ntohl( *( (const int*) chunkdata ) );	/* host byte-order */
+	gint32 value_v;
+
+	memcpy(&value_v, chunkdata, sizeof(value_v));
 
-	return sizeof( int );
+	*value = ntohl(value_v); /* host byte-order */
+
+	return sizeof(value_v);
 }
 
 #if	0

mercurial