aboutsummaryrefslogtreecommitdiff
path: root/src/psycstore
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-12-19 21:58:37 +0000
committerChristian Grothoff <christian@grothoff.org>2014-12-19 21:58:37 +0000
commitbbdd32ba7bb61fe29790ad9d0d05918c5ef08208 (patch)
tree5b9384613bc107df0d55728811ba98c98a5f6f14 /src/psycstore
parent5a6bb4e48c2192b72ee7bf419774bdeeca5f7511 (diff)
downloadgnunet-bbdd32ba7bb61fe29790ad9d0d05918c5ef08208.tar.gz
gnunet-bbdd32ba7bb61fe29790ad9d0d05918c5ef08208.zip
-fix leaks, use asprintf
Diffstat (limited to 'src/psycstore')
-rw-r--r--src/psycstore/plugin_psycstore_sqlite.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/psycstore/plugin_psycstore_sqlite.c b/src/psycstore/plugin_psycstore_sqlite.c
index d282d0948..b0240afd5 100644
--- a/src/psycstore/plugin_psycstore_sqlite.c
+++ b/src/psycstore/plugin_psycstore_sqlite.c
@@ -1770,13 +1770,13 @@ state_get_prefix (void *cls, const struct GNUNET_CRYPTO_EddsaPublicKey *channel_
1770{ 1770{
1771 struct Plugin *plugin = cls; 1771 struct Plugin *plugin = cls;
1772 int ret = GNUNET_SYSERR; 1772 int ret = GNUNET_SYSERR;
1773
1774 sqlite3_stmt *stmt = plugin->select_state_prefix; 1773 sqlite3_stmt *stmt = plugin->select_state_prefix;
1775 size_t name_len = strlen (name); 1774 size_t name_len = strlen (name);
1776 char *name_prefix = GNUNET_malloc (name_len + 2); 1775 char *name_prefix;
1777 memcpy (name_prefix, name, name_len);
1778 memcpy (name_prefix + name_len, "_%", 2);
1779 1776
1777 GNUNET_asprintf (&name_prefix,
1778 "%s_%%",
1779 name);
1780 if (SQLITE_OK != sqlite3_bind_blob (stmt, 1, channel_key, 1780 if (SQLITE_OK != sqlite3_bind_blob (stmt, 1, channel_key,
1781 sizeof (*channel_key), SQLITE_STATIC) 1781 sizeof (*channel_key), SQLITE_STATIC)
1782 || SQLITE_OK != sqlite3_bind_text (stmt, 2, name, name_len, SQLITE_STATIC) 1782 || SQLITE_OK != sqlite3_bind_text (stmt, 2, name, name_len, SQLITE_STATIC)
@@ -1812,13 +1812,12 @@ state_get_prefix (void *cls, const struct GNUNET_CRYPTO_EddsaPublicKey *channel_
1812 } 1812 }
1813 while (sql_ret == SQLITE_ROW); 1813 while (sql_ret == SQLITE_ROW);
1814 } 1814 }
1815
1816 if (SQLITE_OK != sqlite3_reset (stmt)) 1815 if (SQLITE_OK != sqlite3_reset (stmt))
1817 { 1816 {
1818 LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, 1817 LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
1819 "sqlite3_reset"); 1818 "sqlite3_reset");
1820 } 1819 }
1821 1820 GNUNET_free (name_prefix);
1822 return ret; 1821 return ret;
1823} 1822}
1824 1823