Module: sip-router
Branch: 3.3
Commit: d3d1e6947ffe4fbf02a1bddb64d2b9ca969c24a9
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=d3d1e69…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Tue Mar 4 12:04:13 2014 +0100
sqlops: safety check for result row field
- it might not be set in case of a failure in the middle of result
conversion from db to internal memory
- freeing the partial result could result in a crash
- reported by Juha Heinanen
(cherry picked from commit f27df26ca01394250cbe12c5ccf694c6afd3707f)
(cherry picked from commit 20276e667631ec281851c2ef58d71863ae2318c4)
---
modules_k/sqlops/sql_api.c | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/modules_k/sqlops/sql_api.c b/modules_k/sqlops/sql_api.c
index 83b3690..c4c05dc 100644
--- a/modules_k/sqlops/sql_api.c
+++ b/modules_k/sqlops/sql_api.c
@@ -226,13 +226,16 @@ void sql_reset_result(sql_result_t *res)
{
for(i=0; i<res->nrows; i++)
{
- for(j=0; j<res->ncols; j++)
+ if(res->vals[i])
{
- if(res->vals[i][j].flags&PV_VAL_STR
- && res->vals[i][j].value.s.len>0)
- pkg_free(res->vals[i][j].value.s.s);
+ for(j=0; j<res->ncols; j++)
+ {
+ if(res->vals[i][j].flags&PV_VAL_STR
+ && res->vals[i][j].value.s.len>0)
+ pkg_free(res->vals[i][j].value.s.s);
+ }
+ pkg_free(res->vals[i]);
}
- pkg_free(res->vals[i]);
}
pkg_free(res->vals);
res->vals = NULL;