Module: sip-router
Branch: 4.0
Commit: d2f62dd1855faef35bea8eff932d250557868ae5
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=d2f62dd…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Thu Aug 1 15:58:59 2013 +0200
db_flatstore: free id pointer if no more space for table name
- related to previus commit on this module
- keep table name null terminated
(cherry picked from commit 6a981d3d922c914054d4c8dc7e672bb6a4ddb5f5)
---
modules/db_flatstore/km_flat_id.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/modules/db_flatstore/km_flat_id.c b/modules/db_flatstore/km_flat_id.c
index 11f9fbe..99f5a8b 100644
--- a/modules/db_flatstore/km_flat_id.c
+++ b/modules/db_flatstore/km_flat_id.c
@@ -52,9 +52,10 @@ struct flat_id* new_flat_id(char* dir, char* table)
/* alloc memory for the table name */
t_len = strlen(table);
- t = (char*)pkg_malloc(t_len);
+ t = (char*)pkg_malloc(t_len+1);
if (!t) {
LM_ERR("no pkg memory left\n");
+ pkg_free(ptr);
return 0;
}
memset(t, 0, t_len);
@@ -62,6 +63,7 @@ struct flat_id* new_flat_id(char* dir, char* table)
ptr->dir.s = dir;
ptr->dir.len = strlen(dir);
memcpy(t, table, t_len);
+ t[t_len] = '\0';
ptr->table.s = t;
ptr->table.len = t_len;