diff options
author | Brian Cully <bjc@kublai.com> | 2008-07-28 19:00:12 -0400 |
---|---|---|
committer | Brian Cully <github.20.shmit@spamgourmet.com> | 2008-07-28 19:00:12 -0400 |
commit | 08b465f3f26b209965437982040f99408f4dcb19 (patch) | |
tree | 9eb4d26fab1e1a009034ad2d4420d218f8dabac9 /src | |
parent | 76da5d522107d57ddbb4bcdc294a6382a321d524 (diff) | |
download | mysqlerl-08b465f3f26b209965437982040f99408f4dcb19.tar.gz mysqlerl-08b465f3f26b209965437982040f99408f4dcb19.zip |
Fix infinite loop when binding params.
Diffstat (limited to 'src')
-rw-r--r-- | src/mysqlerl.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/mysqlerl.c b/src/mysqlerl.c index 7c88d0d..9aea7c6 100644 --- a/src/mysqlerl.c +++ b/src/mysqlerl.c @@ -290,15 +290,21 @@ handle_param_query(ETERM *msg) } memset(bind, 0, param_count * sizeof(MYSQL_BIND)); - for (i = 0, tmp = params, p = erl_hd(tmp); - p != NULL; + for (i = 0, tmp = params; + (p = erl_hd(tmp)) != NULL && i < 1000; i++, tmp = erl_tl(tmp)) { ETERM *type, *values, *v; - type = erl_element(1, tmp); - values = erl_element(2, tmp); + type = erl_element(1, p); + values = erl_element(2, p); v = erl_hd(values); + fprintf(stderr, "type: "); + erl_print_term(stderr, type); + fprintf(stderr, "\nv: "); + erl_print_term(stderr, values); + fprintf(stderr, "\n"); + if (ERL_IS_TUPLE(type)) { ETERM *t_type, *t_size; char *t; @@ -372,6 +378,7 @@ handle_param_query(ETERM *msg) erl_free_term(values); erl_free_term(type); } + erl_free_term(params); if (mysql_stmt_bind_param(sth, bind)) { resp = erl_format("{error, {mysql_error, ~i, ~s}}", |