Commits

Markus Mottl committed 37cec62

Fixed a memory allocation bug

Comments (0)

Files changed (3)

+2011-12-29:  Fixed a memory allocation bug getting values of binary format.
+
+             Thanks to Igor Plotnikov <igor@xambala.com> for the patch!
+
 2011-05-23:  Fixed conndefaults bindings some more due to unclear PostgreSQL
              documentation.
 
 name="postgresql"
-version="1.16.0"
+version="1.17.0"
 description="PostgreSQL bindings for OCaml"
 requires="unix, bigarray"
 archive(byte)="postgresql.cma"

lib/postgresql_stubs.c

   else {
     /* Assume binary format! */
     size_t len = PQgetlength(res, tup_num, field_num);
-    v_str = len ? v_empty_string : caml_alloc_string(len);
+    v_str = len == 0 ? v_empty_string : caml_alloc_string(len);
     memcpy(String_val(v_str), str, len);
   }
   CAMLreturn(v_str);