From 08b465f3f26b209965437982040f99408f4dcb19 Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Mon, 28 Jul 2008 19:00:12 -0400 Subject: Fix infinite loop when binding params. --- src/mysqlerl.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src') 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}}", -- cgit v1.2.3