Module: kamailio
Branch: master
Commit: f90e785114c7dd738ca7ce7e70d72dd92cbd7136
URL:
https://github.com/kamailio/kamailio/commit/f90e785114c7dd738ca7ce7e70d72dd…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-09-29T13:11:50+02:00
sqlops: keep string values zero-terminated inside db result structure
---
Modified: src/modules/sqlops/sql_api.c
---
Diff:
https://github.com/kamailio/kamailio/commit/f90e785114c7dd738ca7ce7e70d72dd…
Patch:
https://github.com/kamailio/kamailio/commit/f90e785114c7dd738ca7ce7e70d72dd…
---
diff --git a/src/modules/sqlops/sql_api.c b/src/modules/sqlops/sql_api.c
index ddf579cb96..16492300bc 100644
--- a/src/modules/sqlops/sql_api.c
+++ b/src/modules/sqlops/sql_api.c
@@ -394,14 +394,15 @@ int sql_do_query(sql_con_t *con, str *query, sql_result_t *res)
res->vals[i][j].value.s.len = 0;
continue;
}
- res->vals[i][j].value.s.s
- = (char*)pkg_malloc(sv.len*sizeof(char));
+ res->vals[i][j].value.s.s
+ = (char*)pkg_malloc((sv.len+1)*sizeof(char));
if(res->vals[i][j].value.s.s==NULL)
{
LM_ERR("no more memory\n");
goto error;
}
memcpy(res->vals[i][j].value.s.s, sv.s, sv.len);
+ res->vals[i][j].value.s.s[sv.len] = '\0';
res->vals[i][j].value.s.len = sv.len;
}
}