gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r34701 - gnunet/src/psycstore


From: gnunet
Subject: [GNUnet-SVN] r34701 - gnunet/src/psycstore
Date: Fri, 19 Dec 2014 22:58:37 +0100

Author: grothoff
Date: 2014-12-19 22:58:37 +0100 (Fri, 19 Dec 2014)
New Revision: 34701

Modified:
   gnunet/src/psycstore/plugin_psycstore_sqlite.c
Log:
-fix leaks, use asprintf

Modified: gnunet/src/psycstore/plugin_psycstore_sqlite.c
===================================================================
--- gnunet/src/psycstore/plugin_psycstore_sqlite.c      2014-12-19 21:54:51 UTC 
(rev 34700)
+++ gnunet/src/psycstore/plugin_psycstore_sqlite.c      2014-12-19 21:58:37 UTC 
(rev 34701)
@@ -1770,13 +1770,13 @@
 {
   struct Plugin *plugin = cls;
   int ret = GNUNET_SYSERR;
-
   sqlite3_stmt *stmt = plugin->select_state_prefix;
   size_t name_len = strlen (name);
-  char *name_prefix = GNUNET_malloc (name_len + 2);
-  memcpy (name_prefix, name, name_len);
-  memcpy (name_prefix + name_len, "_%", 2);
+  char *name_prefix;
 
+  GNUNET_asprintf (&name_prefix,
+                   "%s_%%",
+                   name);
   if (SQLITE_OK != sqlite3_bind_blob (stmt, 1, channel_key,
                                       sizeof (*channel_key), SQLITE_STATIC)
       || SQLITE_OK != sqlite3_bind_text (stmt, 2, name, name_len, 
SQLITE_STATIC)
@@ -1812,13 +1812,12 @@
     }
     while (sql_ret == SQLITE_ROW);
   }
-
   if (SQLITE_OK != sqlite3_reset (stmt))
   {
     LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                 "sqlite3_reset");
   }
-
+  GNUNET_free (name_prefix);
   return ret;
 }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]