THRIFT-4376: fix a few high impact coverity defects:
1458947: memory leak in compiler
1458787: resource leak in c_glib led to discovery of assert() abuse
1459090: fix string.find result check in JSON processor (unlikely)

This closes #1404
diff --git a/lib/c_glib/test/testbinaryprotocol.c b/lib/c_glib/test/testbinaryprotocol.c
index 58f4df8..14f4fb0 100755
--- a/lib/c_glib/test/testbinaryprotocol.c
+++ b/lib/c_glib/test/testbinaryprotocol.c
@@ -19,7 +19,7 @@
 
 /* Disable string-function optimizations when glibc is used, as these produce
    compiler warnings about string length when a string function is used inside
-   a call to assert () */
+   a call to g_assert () */
 #ifdef __GLIBC__
 #include <features.h>
 #define __NO_STRING_INLINES 1
@@ -28,7 +28,6 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdio.h>
-#include <assert.h>
 #include <netdb.h>
 #include <string.h>
 #include <sys/wait.h>
@@ -96,7 +95,7 @@
 
   /* create an object and then destroy it */
   object = g_object_new (THRIFT_TYPE_BINARY_PROTOCOL, NULL);
-  assert (object != NULL);
+  g_assert (object != NULL);
   g_object_unref (object);
 }
 
@@ -110,11 +109,11 @@
   /* create a ThriftTransport */
   tsocket = g_object_new (THRIFT_TYPE_SOCKET, "hostname", "localhost",
                           "port", 51188, NULL);
-  assert (tsocket != NULL);
+  g_assert (tsocket != NULL);
   /* create a ThriftBinaryProtocol using the Transport */
   protocol = g_object_new (THRIFT_TYPE_BINARY_PROTOCOL, "transport",
                            tsocket, NULL);
-  assert (protocol != NULL);
+  g_assert (protocol != NULL);
   /* fetch the properties */
   g_object_get (G_OBJECT(protocol), "transport", &temp, NULL);
   g_object_unref (temp);
@@ -139,7 +138,7 @@
 
   /* fork a server from the client */
   pid = fork ();
-  assert (pid >= 0);
+  g_assert (pid >= 0);
 
   if (pid == 0)
   {
@@ -155,48 +154,48 @@
                             "port", port, NULL);
     transport = THRIFT_TRANSPORT (tsocket);
     thrift_transport_open (transport, NULL);
-    assert (thrift_transport_is_open (transport));
+    g_assert (thrift_transport_is_open (transport));
 
     /* create a ThriftBinaryTransport */
     tb = g_object_new (THRIFT_TYPE_BINARY_PROTOCOL, "transport",
                        tsocket, NULL);
     protocol = THRIFT_PROTOCOL (tb);
-    assert (protocol != NULL);
+    g_assert (protocol != NULL);
 
     /* write a bunch of primitives */
-    assert (thrift_binary_protocol_write_bool (protocol, TEST_BOOL, NULL) > 0);
-    assert (thrift_binary_protocol_write_byte (protocol, TEST_BYTE, NULL) > 0);
-    assert (thrift_binary_protocol_write_i16 (protocol, TEST_I16, NULL) > 0);
-    assert (thrift_binary_protocol_write_i32 (protocol, TEST_I32, NULL) > 0);
-    assert (thrift_binary_protocol_write_i64 (protocol, TEST_I64, NULL) > 0);
-    assert (thrift_binary_protocol_write_double (protocol, 
+    g_assert (thrift_binary_protocol_write_bool (protocol, TEST_BOOL, NULL) > 0);
+    g_assert (thrift_binary_protocol_write_byte (protocol, TEST_BYTE, NULL) > 0);
+    g_assert (thrift_binary_protocol_write_i16 (protocol, TEST_I16, NULL) > 0);
+    g_assert (thrift_binary_protocol_write_i32 (protocol, TEST_I32, NULL) > 0);
+    g_assert (thrift_binary_protocol_write_i64 (protocol, TEST_I64, NULL) > 0);
+    g_assert (thrift_binary_protocol_write_double (protocol, 
                                                  TEST_DOUBLE, NULL) > 0);
-    assert (thrift_binary_protocol_write_string (protocol,
+    g_assert (thrift_binary_protocol_write_string (protocol,
                                                  TEST_STRING, NULL) > 0);
-    assert (thrift_binary_protocol_write_string (protocol, "", NULL) > 0);
-    assert (thrift_binary_protocol_write_binary (protocol, binary, 
+    g_assert (thrift_binary_protocol_write_string (protocol, "", NULL) > 0);
+    g_assert (thrift_binary_protocol_write_binary (protocol, binary, 
                                                  len, NULL) > 0);
-    assert (thrift_binary_protocol_write_binary (protocol, NULL, 0, NULL) > 0);
-    assert (thrift_binary_protocol_write_binary (protocol, binary,
+    g_assert (thrift_binary_protocol_write_binary (protocol, NULL, 0, NULL) > 0);
+    g_assert (thrift_binary_protocol_write_binary (protocol, binary,
                                                  len, NULL) > 0);
 
     /* test write errors */
     transport_write_error = 1;
-    assert (thrift_binary_protocol_write_byte (protocol, TEST_BYTE, 
+    g_assert (thrift_binary_protocol_write_byte (protocol, TEST_BYTE, 
                                                NULL) == -1);
-    assert (thrift_binary_protocol_write_i16 (protocol, TEST_I16, NULL) == -1);
-    assert (thrift_binary_protocol_write_i32 (protocol, TEST_I32, NULL) == -1);
-    assert (thrift_binary_protocol_write_i64 (protocol, TEST_I64, NULL) == -1);
-    assert (thrift_binary_protocol_write_double (protocol, TEST_DOUBLE,
+    g_assert (thrift_binary_protocol_write_i16 (protocol, TEST_I16, NULL) == -1);
+    g_assert (thrift_binary_protocol_write_i32 (protocol, TEST_I32, NULL) == -1);
+    g_assert (thrift_binary_protocol_write_i64 (protocol, TEST_I64, NULL) == -1);
+    g_assert (thrift_binary_protocol_write_double (protocol, TEST_DOUBLE,
                                                  NULL) == -1);
-    assert (thrift_binary_protocol_write_binary (protocol, binary, len,
+    g_assert (thrift_binary_protocol_write_binary (protocol, binary, len,
                                                  NULL) == -1);
     transport_write_error = 0;
 
     /* test binary partial failure */
     transport_write_count = 0;
     transport_write_error_at = 1;
-    assert (thrift_binary_protocol_write_binary (protocol, binary,
+    g_assert (thrift_binary_protocol_write_binary (protocol, binary,
                                                  len, NULL) == -1);
     transport_write_error_at = -1;
 
@@ -204,8 +203,8 @@
     thrift_transport_close (transport, NULL);
     g_object_unref (tsocket);
     g_object_unref (protocol);
-    assert (wait (&status) == pid);
-    assert (status == 0);
+    g_assert (wait (&status) == pid);
+    g_assert (status == 0);
   }
 }
 
@@ -222,7 +221,7 @@
 
   /* fork a server from the client */
   pid = fork ();
-  assert (pid >= 0);
+  g_assert (pid >= 0);
 
   if (pid == 0)
   {
@@ -238,33 +237,33 @@
                             "port", port, NULL);
     transport = THRIFT_TRANSPORT (tsocket);
     thrift_transport_open (transport, NULL);
-    assert (thrift_transport_is_open (transport));
+    g_assert (thrift_transport_is_open (transport));
 
     /* create a ThriftBinaryTransport */
     tb = g_object_new (THRIFT_TYPE_BINARY_PROTOCOL, "transport",
                        tsocket, NULL);
     protocol = THRIFT_PROTOCOL (tb);
-    assert (protocol != NULL);
+    g_assert (protocol != NULL);
 
     /* test structures */
-    assert (thrift_binary_protocol_write_struct_begin (protocol, 
+    g_assert (thrift_binary_protocol_write_struct_begin (protocol, 
                                                        NULL, NULL) == 0);
-    assert (thrift_binary_protocol_write_struct_end (protocol, NULL) == 0);
+    g_assert (thrift_binary_protocol_write_struct_end (protocol, NULL) == 0);
 
-    assert (thrift_binary_protocol_write_field_begin (protocol, "test", T_VOID,
+    g_assert (thrift_binary_protocol_write_field_begin (protocol, "test", T_VOID,
                                                       1, NULL) > 0);
-    assert (thrift_binary_protocol_write_field_end (protocol, NULL) == 0);
+    g_assert (thrift_binary_protocol_write_field_end (protocol, NULL) == 0);
 
     /* test write error */
     transport_write_error = 1;
-    assert (thrift_binary_protocol_write_field_begin (protocol, "test", T_VOID, 
+    g_assert (thrift_binary_protocol_write_field_begin (protocol, "test", T_VOID, 
                                                       1, NULL) == -1);
     transport_write_error = 0;
 
     /* test 2nd write error */
     transport_write_count = 0;
     transport_write_error_at = 1;
-    assert (thrift_binary_protocol_write_field_begin (protocol, "test", T_VOID,
+    g_assert (thrift_binary_protocol_write_field_begin (protocol, "test", T_VOID,
                                                       1, NULL) == -1);
     transport_write_error_at = -1;
 
@@ -272,12 +271,12 @@
     thrift_binary_protocol_write_byte (protocol, T_VOID, NULL);
 
     /* test write_field_stop */
-    assert (thrift_binary_protocol_write_field_stop (protocol, NULL) > 0);
+    g_assert (thrift_binary_protocol_write_field_stop (protocol, NULL) > 0);
 
     /* write a map */
-    assert (thrift_binary_protocol_write_map_begin (protocol, T_VOID, T_VOID,
+    g_assert (thrift_binary_protocol_write_map_begin (protocol, T_VOID, T_VOID,
                                                     1, NULL) > 0);
-    assert (thrift_binary_protocol_write_map_end (protocol, NULL) == 0);
+    g_assert (thrift_binary_protocol_write_map_end (protocol, NULL) == 0);
 
     /* test 2nd read failure on a map */
     thrift_binary_protocol_write_byte (protocol, T_VOID, NULL);
@@ -288,21 +287,21 @@
 
     /* test 1st write failure on a map */
     transport_write_error = 1;
-    assert (thrift_binary_protocol_write_map_begin (protocol, T_VOID, T_VOID,
+    g_assert (thrift_binary_protocol_write_map_begin (protocol, T_VOID, T_VOID,
                                                     1, NULL) == -1);
     transport_write_error = 0;
 
     /* test 2nd write failure on a map */
     transport_write_count = 0;
     transport_write_error_at = 1;
-    assert (thrift_binary_protocol_write_map_begin (protocol, T_VOID, T_VOID,
+    g_assert (thrift_binary_protocol_write_map_begin (protocol, T_VOID, T_VOID,
                                                     1, NULL) == -1);
     transport_write_error_at = -1;
 
     /* test 3rd write failure on a map */
     transport_write_count = 0;
     transport_write_error_at = 2;
-    assert (thrift_binary_protocol_write_map_begin (protocol, T_VOID, T_VOID,
+    g_assert (thrift_binary_protocol_write_map_begin (protocol, T_VOID, T_VOID,
                                                     1, NULL) == -1);
     transport_write_error_at = -1;
 
@@ -312,9 +311,9 @@
     thrift_binary_protocol_write_i32 (protocol, -10, NULL);
 
     /* test list operations */
-    assert (thrift_binary_protocol_write_list_begin (protocol, T_VOID,
+    g_assert (thrift_binary_protocol_write_list_begin (protocol, T_VOID,
                                                      1, NULL) > 0);
-    assert (thrift_binary_protocol_write_list_end (protocol, NULL) == 0);
+    g_assert (thrift_binary_protocol_write_list_end (protocol, NULL) == 0);
 
     /* test 2nd read failure on a list */
     thrift_binary_protocol_write_byte (protocol, T_VOID, NULL);
@@ -325,27 +324,27 @@
 
     /* test first write error on a list */
     transport_write_error = 1;
-    assert (thrift_binary_protocol_write_list_begin (protocol, T_VOID,
+    g_assert (thrift_binary_protocol_write_list_begin (protocol, T_VOID,
                                                      1, NULL) == -1);
     transport_write_error = 0;
 
     /* test 2nd write error on a list */
     transport_write_count = 0;
     transport_write_error_at = 1;
-    assert (thrift_binary_protocol_write_list_begin (protocol, T_VOID,
+    g_assert (thrift_binary_protocol_write_list_begin (protocol, T_VOID,
                                                      1, NULL) == -1);
     transport_write_error_at = -1;
 
     /* test set operation s*/
-    assert (thrift_binary_protocol_write_set_begin (protocol, T_VOID,
+    g_assert (thrift_binary_protocol_write_set_begin (protocol, T_VOID,
                                                     1, NULL) > 0);
-    assert (thrift_binary_protocol_write_set_end (protocol, NULL) == 0);
+    g_assert (thrift_binary_protocol_write_set_end (protocol, NULL) == 0);
 
     /* invalid version */
-    assert (thrift_binary_protocol_write_i32 (protocol, -1, NULL) > 0);
+    g_assert (thrift_binary_protocol_write_i32 (protocol, -1, NULL) > 0);
 
     /* sz > 0 for a message */
-    assert (thrift_binary_protocol_write_i32 (protocol, 1, NULL) > 0);
+    g_assert (thrift_binary_protocol_write_i32 (protocol, 1, NULL) > 0);
 
     /* send a valid message */
     thrift_binary_protocol_write_i32 (protocol, 0x80010000, NULL);
@@ -360,26 +359,26 @@
     thrift_binary_protocol_write_string (protocol, "test", NULL);
 
     /* send a valid message */
-    assert (thrift_binary_protocol_write_message_begin (protocol, "test",
+    g_assert (thrift_binary_protocol_write_message_begin (protocol, "test",
                                                         T_CALL, 1, NULL) > 0);
 
-    assert (thrift_binary_protocol_write_message_end (protocol, NULL) == 0);
+    g_assert (thrift_binary_protocol_write_message_end (protocol, NULL) == 0);
 
     /* send broken writes */
     transport_write_error = 1;
-    assert (thrift_binary_protocol_write_message_begin (protocol, "test",
+    g_assert (thrift_binary_protocol_write_message_begin (protocol, "test",
                                                         T_CALL, 1, NULL) == -1);
     transport_write_error = 0;
 
     transport_write_count = 0;
     transport_write_error_at = 2;
-    assert (thrift_binary_protocol_write_message_begin (protocol, "test",
+    g_assert (thrift_binary_protocol_write_message_begin (protocol, "test",
                                                         T_CALL, 1, NULL) == -1);
     transport_write_error_at = -1;
 
     transport_write_count = 0;
     transport_write_error_at = 3;
-    assert (thrift_binary_protocol_write_message_begin (protocol, "test",
+    g_assert (thrift_binary_protocol_write_message_begin (protocol, "test",
                                                         T_CALL, 1, NULL) == -1);
     transport_write_error_at = -1;
 
@@ -387,8 +386,8 @@
     thrift_transport_close (transport, NULL);
     g_object_unref (tsocket);
     g_object_unref (protocol);
-    assert (wait (&status) == pid);
-    assert (status == 0);
+    g_assert (wait (&status) == pid);
+    g_assert (status == 0);
   }
 }
 
@@ -408,7 +407,7 @@
 
   /* fork a server from the client */
   pid = fork ();
-  assert (pid >= 0);
+  g_assert (pid >= 0);
 
   if (pid == 0)
   {
@@ -422,49 +421,49 @@
     /* create a ThriftSocket */
     tsocket = g_object_new (THRIFT_TYPE_SOCKET, "hostname", "localhost",
                             "port", port, NULL);
-    assert (tsocket != NULL);
+    g_assert (tsocket != NULL);
     transport = THRIFT_TRANSPORT (tsocket);
 
     /* wrap in a framed transport */
     ft = g_object_new (THRIFT_TYPE_FRAMED_TRANSPORT, "transport", transport,
                        "w_buf_size", 1, NULL);
-    assert (ft != NULL);
+    g_assert (ft != NULL);
     transport = THRIFT_TRANSPORT (ft);
 
     thrift_transport_open (transport, NULL);
-    assert (thrift_transport_is_open (transport));
+    g_assert (thrift_transport_is_open (transport));
 
     /* create a binary protocol */
     tb = g_object_new (THRIFT_TYPE_BINARY_PROTOCOL, "transport",
                        transport, NULL);
     protocol = THRIFT_PROTOCOL (tb);
-    assert (protocol != NULL);
+    g_assert (protocol != NULL);
 
     /* write a bunch of primitives */
-    assert (thrift_binary_protocol_write_bool (protocol, TEST_BOOL, NULL) > 0);
+    g_assert (thrift_binary_protocol_write_bool (protocol, TEST_BOOL, NULL) > 0);
     thrift_transport_flush (transport, NULL);
-    assert (thrift_binary_protocol_write_byte (protocol, TEST_BYTE, NULL) > 0);
+    g_assert (thrift_binary_protocol_write_byte (protocol, TEST_BYTE, NULL) > 0);
     thrift_transport_flush (transport, NULL);
-    assert (thrift_binary_protocol_write_i16 (protocol, TEST_I16, NULL) > 0);
+    g_assert (thrift_binary_protocol_write_i16 (protocol, TEST_I16, NULL) > 0);
     thrift_transport_flush (transport, NULL);
-    assert (thrift_binary_protocol_write_i32 (protocol, TEST_I32, NULL) > 0);
+    g_assert (thrift_binary_protocol_write_i32 (protocol, TEST_I32, NULL) > 0);
     thrift_transport_flush (transport, NULL);
-    assert (thrift_binary_protocol_write_i64 (protocol, TEST_I64, NULL) > 0);
+    g_assert (thrift_binary_protocol_write_i64 (protocol, TEST_I64, NULL) > 0);
     thrift_transport_flush (transport, NULL);
-    assert (thrift_binary_protocol_write_double (protocol,
+    g_assert (thrift_binary_protocol_write_double (protocol,
                                                  TEST_DOUBLE, NULL) > 0);
     thrift_transport_flush (transport, NULL);
-    assert (thrift_binary_protocol_write_string (protocol,
+    g_assert (thrift_binary_protocol_write_string (protocol,
                                                  TEST_STRING, NULL) > 0);
     thrift_transport_flush (transport, NULL);
-    assert (thrift_binary_protocol_write_string (protocol, "", NULL) > 0);
+    g_assert (thrift_binary_protocol_write_string (protocol, "", NULL) > 0);
     thrift_transport_flush (transport, NULL);
-    assert (thrift_binary_protocol_write_binary (protocol, binary,
+    g_assert (thrift_binary_protocol_write_binary (protocol, binary,
                                                  len, NULL) > 0);
     thrift_transport_flush (transport, NULL);
-    assert (thrift_binary_protocol_write_binary (protocol, NULL, 0, NULL) > 0);
+    g_assert (thrift_binary_protocol_write_binary (protocol, NULL, 0, NULL) > 0);
     thrift_transport_flush (transport, NULL);
-    assert (thrift_binary_protocol_write_binary (protocol, binary,
+    g_assert (thrift_binary_protocol_write_binary (protocol, binary,
                                                  len, NULL) > 0);
     thrift_transport_flush (transport, NULL);
 
@@ -474,8 +473,8 @@
     g_object_unref (ft);
     g_object_unref (tsocket);
     g_object_unref (tb);
-    assert (wait (&status) == pid);
-    assert (status == 0);
+    g_assert (wait (&status) == pid);
+    g_assert (status == 0);
   }
 }
 
@@ -504,68 +503,68 @@
   transport = THRIFT_SERVER_TRANSPORT (tsocket);
   thrift_server_transport_listen (transport, NULL);
   client = thrift_server_transport_accept (transport, NULL);
-  assert (client != NULL);
+  g_assert (client != NULL);
 
   tbp = g_object_new (THRIFT_TYPE_BINARY_PROTOCOL, "transport",
                       client, NULL);
   protocol = THRIFT_PROTOCOL (tbp);
 
-  assert (thrift_binary_protocol_read_bool (protocol,
+  g_assert (thrift_binary_protocol_read_bool (protocol,
                                             &value_boolean, NULL) > 0);
-  assert (thrift_binary_protocol_read_byte (protocol, &value_byte, NULL) > 0);
-  assert (thrift_binary_protocol_read_i16 (protocol, &value_16, NULL) > 0);
-  assert (thrift_binary_protocol_read_i32 (protocol, &value_32, NULL) > 0);
-  assert (thrift_binary_protocol_read_i64 (protocol, &value_64, NULL) > 0);
-  assert (thrift_binary_protocol_read_double (protocol,
+  g_assert (thrift_binary_protocol_read_byte (protocol, &value_byte, NULL) > 0);
+  g_assert (thrift_binary_protocol_read_i16 (protocol, &value_16, NULL) > 0);
+  g_assert (thrift_binary_protocol_read_i32 (protocol, &value_32, NULL) > 0);
+  g_assert (thrift_binary_protocol_read_i64 (protocol, &value_64, NULL) > 0);
+  g_assert (thrift_binary_protocol_read_double (protocol,
                                               &value_double, NULL) > 0);
-  assert (thrift_binary_protocol_read_string (protocol, &string, NULL) > 0);
-  assert (thrift_binary_protocol_read_string (protocol, &empty_string,
+  g_assert (thrift_binary_protocol_read_string (protocol, &string, NULL) > 0);
+  g_assert (thrift_binary_protocol_read_string (protocol, &empty_string,
                                               NULL) > 0);
-  assert (thrift_binary_protocol_read_binary (protocol, &binary,
+  g_assert (thrift_binary_protocol_read_binary (protocol, &binary,
                                               &len, NULL) > 0);
 
-  assert (value_boolean == TEST_BOOL);
-  assert (value_byte == TEST_BYTE);
-  assert (value_16 == TEST_I16);
-  assert (value_32 == TEST_I32);
-  assert (value_64 == TEST_I64);
-  assert (value_double == TEST_DOUBLE);
-  assert (strcmp (TEST_STRING, string) == 0);
-  assert (strcmp ("", empty_string) == 0);
-  assert (memcmp (comparator, binary, len) == 0);
+  g_assert (value_boolean == TEST_BOOL);
+  g_assert (value_byte == TEST_BYTE);
+  g_assert (value_16 == TEST_I16);
+  g_assert (value_32 == TEST_I32);
+  g_assert (value_64 == TEST_I64);
+  g_assert (value_double == TEST_DOUBLE);
+  g_assert (strcmp (TEST_STRING, string) == 0);
+  g_assert (strcmp ("", empty_string) == 0);
+  g_assert (memcmp (comparator, binary, len) == 0);
 
   g_free (string);
   g_free (empty_string);
   g_free (binary);
 
-  assert (thrift_binary_protocol_read_binary (protocol, &binary,
+  g_assert (thrift_binary_protocol_read_binary (protocol, &binary,
                                               &len, NULL) > 0);
-  assert (binary == NULL);
-  assert (len == 0);
+  g_assert (binary == NULL);
+  g_assert (len == 0);
   g_free (binary);
 
   transport_read_count = 0;
   transport_read_error_at = 0;
-  assert (thrift_binary_protocol_read_binary (protocol, &binary,
+  g_assert (thrift_binary_protocol_read_binary (protocol, &binary,
                                               &len, NULL) == -1);
   transport_read_error_at = -1;
 
   transport_read_count = 0;
   transport_read_error_at = 1;
-  assert (thrift_binary_protocol_read_binary (protocol, &binary,
+  g_assert (thrift_binary_protocol_read_binary (protocol, &binary,
                                               &len, NULL) == -1);
   transport_read_error_at = -1;
 
   transport_read_error = 1;
-  assert (thrift_binary_protocol_read_bool (protocol,
+  g_assert (thrift_binary_protocol_read_bool (protocol,
                                             &value_boolean, NULL) == -1);
-  assert (thrift_binary_protocol_read_byte (protocol,
+  g_assert (thrift_binary_protocol_read_byte (protocol,
                                             &value_byte, NULL) == -1);
-  assert (thrift_binary_protocol_read_i16 (protocol,
+  g_assert (thrift_binary_protocol_read_i16 (protocol,
                                            &value_16, NULL) == -1);
-  assert (thrift_binary_protocol_read_i32 (protocol, &value_32, NULL) == -1);
-  assert (thrift_binary_protocol_read_i64 (protocol, &value_64, NULL) == -1);
-  assert (thrift_binary_protocol_read_double (protocol,
+  g_assert (thrift_binary_protocol_read_i32 (protocol, &value_32, NULL) == -1);
+  g_assert (thrift_binary_protocol_read_i64 (protocol, &value_64, NULL) == -1);
+  g_assert (thrift_binary_protocol_read_double (protocol,
                                               &value_double, NULL) == -1);
   transport_read_error = 0;
 
@@ -603,7 +602,7 @@
   transport = THRIFT_SERVER_TRANSPORT (tsocket);
   thrift_server_transport_listen (transport, NULL);
   client = thrift_server_transport_accept (transport, NULL);
-  assert (client != NULL);
+  g_assert (client != NULL);
 
   tbp = g_object_new (THRIFT_TYPE_BINARY_PROTOCOL, "transport",
                       client, NULL);
@@ -618,7 +617,7 @@
 
   /* test first read error on a field */
   transport_read_error = 1;
-  assert (thrift_binary_protocol_read_field_begin (protocol,
+  g_assert (thrift_binary_protocol_read_field_begin (protocol,
                                                    &field_name, &field_type,
                                                    &field_id, NULL) == -1);
   transport_read_error = 0;
@@ -629,7 +628,7 @@
   /* test 2nd read failure on a field */
   transport_read_count = 0;
   transport_read_error_at = 1;
-  assert (thrift_binary_protocol_read_field_begin (protocol,
+  g_assert (thrift_binary_protocol_read_field_begin (protocol,
                                                    &field_name, &field_type,
                                                    &field_id, NULL) == -1);
   transport_read_error_at = -1;
@@ -645,7 +644,7 @@
   /* test read failure on a map */
   transport_read_count = 0;
   transport_read_error_at = 0;
-  assert (thrift_binary_protocol_read_map_begin (protocol,
+  g_assert (thrift_binary_protocol_read_map_begin (protocol,
                                                  &key_type, &value_type,
                                                  &size, NULL) == -1);
   transport_read_error_at = -1;
@@ -653,7 +652,7 @@
   /* test 2nd read failure on a map */
   transport_read_count = 0;
   transport_read_error_at = 1;
-  assert (thrift_binary_protocol_read_map_begin (protocol,
+  g_assert (thrift_binary_protocol_read_map_begin (protocol,
                                                  &key_type, &value_type,
                                                  &size, NULL) == -1);
   transport_read_error_at = -1;
@@ -661,7 +660,7 @@
   /* test 3rd read failure on a map */
   transport_read_count = 0;
   transport_read_error_at = 2;
-  assert (thrift_binary_protocol_read_map_begin (protocol,
+  g_assert (thrift_binary_protocol_read_map_begin (protocol,
                                                  &key_type, &value_type,
                                                  &size, NULL) == -1);
   transport_read_error_at = -1;
@@ -674,7 +673,7 @@
   thrift_binary_protocol_read_byte (protocol, &value, NULL);
 
   /* test negative map size */
-  assert (thrift_binary_protocol_read_map_begin (protocol,
+  g_assert (thrift_binary_protocol_read_map_begin (protocol,
                                                  &key_type, &value_type,
                                                  &size, NULL) == -1);
 
@@ -684,7 +683,7 @@
 
   /* test read failure */
   transport_read_error = 1;
-  assert (thrift_binary_protocol_read_list_begin (protocol, &element_type,
+  g_assert (thrift_binary_protocol_read_list_begin (protocol, &element_type,
                                                   &size, NULL) == -1);
   transport_read_error = 0;
 
@@ -706,23 +705,23 @@
 
   /* broken read */
   transport_read_error = 1;
-  assert (thrift_binary_protocol_read_message_begin (protocol, &message_name,
+  g_assert (thrift_binary_protocol_read_message_begin (protocol, &message_name,
                                                      &message_type, &seqid,
                                                      NULL) == -1);
   transport_read_error = 0;
 
   /* invalid protocol version */
-  assert (thrift_binary_protocol_read_message_begin (protocol, &message_name,
+  g_assert (thrift_binary_protocol_read_message_begin (protocol, &message_name,
                                                      &message_type, &seqid,
                                                      NULL) == -1);
 
   /* sz > 0 */
-  assert (thrift_binary_protocol_read_message_begin (protocol, &message_name,
+  g_assert (thrift_binary_protocol_read_message_begin (protocol, &message_name,
                                                      &message_type, &seqid,
                                                      NULL) > 0);
 
   /* read a valid message */
-  assert (thrift_binary_protocol_read_message_begin (protocol, &message_name,
+  g_assert (thrift_binary_protocol_read_message_begin (protocol, &message_name,
                                                      &message_type, &seqid,
                                                      NULL) > 0);
   g_free (message_name);
@@ -730,7 +729,7 @@
   /* broken 2nd read on a message */
   transport_read_count = 0;
   transport_read_error_at = 1;
-  assert (thrift_binary_protocol_read_message_begin (protocol, &message_name,
+  g_assert (thrift_binary_protocol_read_message_begin (protocol, &message_name,
                                                      &message_type, &seqid,
                                                      NULL) == -1);
   transport_read_error_at = -1;
@@ -738,19 +737,19 @@
   /* broken 3rd read on a message */
   transport_read_count = 0;
   transport_read_error_at = 3; /* read_string does two reads */
-  assert (thrift_binary_protocol_read_message_begin (protocol, &message_name,
+  g_assert (thrift_binary_protocol_read_message_begin (protocol, &message_name,
                                                      &message_type, &seqid,
                                                      NULL) == -1);
   g_free (message_name);
   transport_read_error_at = -1;
 
   /* read a valid message */
-  assert (thrift_binary_protocol_read_message_begin (protocol, &message_name,
+  g_assert (thrift_binary_protocol_read_message_begin (protocol, &message_name,
                                                      &message_type, &seqid, 
                                                      NULL) > 0);
   g_free (message_name);
 
-  assert (thrift_binary_protocol_read_message_end (protocol, NULL) == 0);
+  g_assert (thrift_binary_protocol_read_message_end (protocol, NULL) == 0);
 
   /* handle 2nd write failure on a message */
   thrift_binary_protocol_read_i32 (protocol, &version, NULL);
@@ -792,44 +791,44 @@
   client = g_object_new (THRIFT_TYPE_FRAMED_TRANSPORT, "transport",
                          thrift_server_transport_accept (transport, NULL),
                          "r_buf_size", 1, NULL);
-  assert (client != NULL);
+  g_assert (client != NULL);
 
   tbp = g_object_new (THRIFT_TYPE_BINARY_PROTOCOL, "transport",
                       client, NULL);
   protocol = THRIFT_PROTOCOL (tbp);
 
-  assert (thrift_binary_protocol_read_bool (protocol,
+  g_assert (thrift_binary_protocol_read_bool (protocol,
                                             &value_boolean, NULL) > 0);
-  assert (thrift_binary_protocol_read_byte (protocol, &value_byte, NULL) > 0);
-  assert (thrift_binary_protocol_read_i16 (protocol, &value_16, NULL) > 0);
-  assert (thrift_binary_protocol_read_i32 (protocol, &value_32, NULL) > 0);
-  assert (thrift_binary_protocol_read_i64 (protocol, &value_64, NULL) > 0);
-  assert (thrift_binary_protocol_read_double (protocol,
+  g_assert (thrift_binary_protocol_read_byte (protocol, &value_byte, NULL) > 0);
+  g_assert (thrift_binary_protocol_read_i16 (protocol, &value_16, NULL) > 0);
+  g_assert (thrift_binary_protocol_read_i32 (protocol, &value_32, NULL) > 0);
+  g_assert (thrift_binary_protocol_read_i64 (protocol, &value_64, NULL) > 0);
+  g_assert (thrift_binary_protocol_read_double (protocol,
                                               &value_double, NULL) > 0);
-  assert (thrift_binary_protocol_read_string (protocol, &string, NULL) > 0);
-  assert (thrift_binary_protocol_read_string (protocol, &empty_string,
+  g_assert (thrift_binary_protocol_read_string (protocol, &string, NULL) > 0);
+  g_assert (thrift_binary_protocol_read_string (protocol, &empty_string,
                                               NULL) > 0);
-  assert (thrift_binary_protocol_read_binary (protocol, &binary,
+  g_assert (thrift_binary_protocol_read_binary (protocol, &binary,
                                               &len, NULL) > 0);
 
-  assert (value_boolean == TEST_BOOL);
-  assert (value_byte == TEST_BYTE);
-  assert (value_16 == TEST_I16);
-  assert (value_32 == TEST_I32);
-  assert (value_64 == TEST_I64);
-  assert (value_double == TEST_DOUBLE);
-  assert (strcmp (TEST_STRING, string) == 0);
-  assert (strcmp ("", empty_string) == 0);
-  assert (memcmp (comparator, binary, len) == 0);
+  g_assert (value_boolean == TEST_BOOL);
+  g_assert (value_byte == TEST_BYTE);
+  g_assert (value_16 == TEST_I16);
+  g_assert (value_32 == TEST_I32);
+  g_assert (value_64 == TEST_I64);
+  g_assert (value_double == TEST_DOUBLE);
+  g_assert (strcmp (TEST_STRING, string) == 0);
+  g_assert (strcmp ("", empty_string) == 0);
+  g_assert (memcmp (comparator, binary, len) == 0);
 
   g_free (string);
   g_free (empty_string);
   g_free (binary);
 
-  assert (thrift_binary_protocol_read_binary (protocol, &binary,
+  g_assert (thrift_binary_protocol_read_binary (protocol, &binary,
                                               &len, NULL) > 0);
-  assert (binary == NULL);
-  assert (len == 0);
+  g_assert (binary == NULL);
+  g_assert (len == 0);
   g_free (binary);
 
   thrift_transport_read_end (client, NULL);