summaryrefslogtreecommitdiff
path: root/client/mysqltest.c
diff options
context:
space:
mode:
authormsvensson@neptunus.(none) <>2005-09-01 10:53:33 +0200
committermsvensson@neptunus.(none) <>2005-09-01 10:53:33 +0200
commitced32517c78cc0c5e723caccceaaf1ff534baf3e (patch)
treec9c4d317c11fe2b6421a62743b37e517715ad912 /client/mysqltest.c
parent906f7c4481fbd209f61809989b2b1f8d92869037 (diff)
downloadmariadb-git-ced32517c78cc0c5e723caccceaaf1ff534baf3e.tar.gz
Bug #3131 mysqltest fails on $2=$1 assignment in test
Diffstat (limited to 'client/mysqltest.c')
-rw-r--r--client/mysqltest.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/client/mysqltest.c b/client/mysqltest.c
index 3b13084081e..6c7d51c393d 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -1147,16 +1147,24 @@ int var_query_set(VAR* v, const char *p, const char** p_end)
return 0;
}
-void var_copy(VAR* dest, VAR* src)
+void var_copy(VAR *dest, VAR *src)
{
- dest->int_val=src->int_val;
- dest->int_dirty=src->int_dirty;
+ dest->int_val= src->int_val;
+ dest->int_dirty= src->int_dirty;
+
+ /* Alloc/realloc data for str_val in dest */
if (dest->alloced_len < src->alloced_len &&
- !(dest->str_val=my_realloc(dest->str_val,src->alloced_len+1,
- MYF(MY_WME))))
+ !(dest->str_val= dest->str_val
+ ? my_realloc(dest->str_val, src->alloced_len, MYF(MY_WME))
+ : my_malloc(src->alloced_len, MYF(MY_WME))))
die("Out of memory");
- dest->str_val_len=src->str_val_len;
- memcpy(dest->str_val,src->str_val,src->str_val_len+1);
+ else
+ dest->alloced_len= src->alloced_len;
+
+ /* Copy str_val data to dest */
+ dest->str_val_len= src->str_val_len;
+ if (src->str_val_len)
+ memcpy(dest->str_val, src->str_val, src->str_val_len);
}
int eval_expr(VAR* v, const char *p, const char** p_end)