ygrek / ocaml-mysql

OCaml bindings to libmysqlclient
https://ygrek.org.ua/p/ocaml-mysql
GNU Lesser General Public License v2.1
23 stars 11 forks source link

Segfault when calling fetch_fields on a prepared statement's result metadata #5

Closed hcarty closed 8 years ago

hcarty commented 8 years ago

... before a result has actually been returned. I ran into this in the toplevel (OCaml 4.02.3 64bit, Mac OSX, MySQL 5.7 client library).

# let dbd =
  Mysql.quick_connect
    ~host:"127.0.0.1" ~port:3306 ~database:"db"
    ~user:"user" ~password:"password" ();;
val dbd : Mysql.dbd = <abstr>
# Mysql.exec dbd "create table test (id int, name char(64))";;
- : Mysql.result = <abstr>
# let stmt = Mysql.Prepared.create dbd "insert into test (id, name) values (?, ?)";;
val stmt : Mysql.Prepared.stmt = <abstr>
# let result = Mysql.Prepared.result_metadata stmt;;
val result : Mysql.result = <abstr>
# Mysql.fetch_fields result;;
Segmentation fault: 11
ygrek commented 8 years ago

Thanks for the report, fetch_fields binding didn't account for the fact that NULL is a valid value for MYSQL_RES.

hcarty commented 8 years ago

Thank you for the quick fix!

hcarty commented 8 years ago

Could you make a bugfix release with this change in place?

ygrek commented 8 years ago

Done https://github.com/ocaml/opam-repository/pull/7044

hcarty commented 8 years ago

Thank you!