[sr-dev] git:sr_3.0: db_postgres: reset row_buf for each row

Andrei Pelinescu-Onciul andrei at iptel.org
Mon Oct 11 11:19:06 CEST 2010


Module: sip-router
Branch: sr_3.0
Commit: b0da607b75c978282b49a31d2858177ec6232941
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=b0da607b75c978282b49a31d2858177ec6232941

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Andrei Pelinescu-Onciul <andrei at iptel.org>
Date:   Sat Sep 18 11:58:21 2010 +0200

db_postgres: reset row_buf for each row

- DB1 interface was reusing local buffer to convert returned rows,
  resulting in misusage of values from previous rows for null values
- reported by Jan Klepal
(cherry picked from commit 63c724b42d4c4ff45eaa660508d6358f3e894d0a)

---

 modules/db_postgres/km_res.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/modules/db_postgres/km_res.c b/modules/db_postgres/km_res.c
index c4148ec..106ad22 100644
--- a/modules/db_postgres/km_res.c
+++ b/modules/db_postgres/km_res.c
@@ -220,7 +220,6 @@ int db_postgres_convert_rows(const db1_con_t* _h, db1_res_t* _r)
 		return -1;
 	}
 	LM_DBG("allocate for %d columns %d bytes in row buffer at %p\n", RES_COL_N(_r), len, row_buf);
-	memset(row_buf, 0, len);
 
 	if (db_allocate_rows(_r) < 0) {
 		LM_ERR("could not allocate rows\n");
@@ -230,6 +229,8 @@ int db_postgres_convert_rows(const db1_con_t* _h, db1_res_t* _r)
 	}
 
 	for(row = RES_LAST_ROW(_r); row < (RES_LAST_ROW(_r) + RES_ROW_N(_r)); row++) {
+		/* reset row buf content */
+		memset(row_buf, 0, len);
 		for(col = 0; col < RES_COL_N(_r); col++) {
 			/*
 			 * The row data pointer returned by PQgetvalue points to storage




More information about the sr-dev mailing list