[almanah] vfs: Avoiding a memory leak with the filenames strings
- From: Álvaro Peña <alvaropg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [almanah] vfs: Avoiding a memory leak with the filenames strings
- Date: Fri, 5 Dec 2014 18:31:04 +0000 (UTC)
commit 94e3d5a2dac6eee2cdc41a20c5754a9d01929443
Author: Álvaro Peña <alvaropg gmail com>
Date: Fri Dec 5 19:20:54 2014 +0100
vfs: Avoiding a memory leak with the filenames strings
src/vfs.c | 16 ++++++++++++++--
1 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/src/vfs.c b/src/vfs.c
index 62b342b..c782147 100644
--- a/src/vfs.c
+++ b/src/vfs.c
@@ -685,6 +685,12 @@ demoClose (sqlite3_file *pFile)
if (self->plain_buffer)
gcr_secure_memory_free (self->plain_buffer);
+ if (self->plain_filename)
+ g_free (self->plain_filename);
+
+ if (self->encrypted_filename)
+ g_free (self->encrypted_filename);
+
return rc;
}
@@ -999,14 +1005,20 @@ demoOpen (__attribute__ ((unused)) sqlite3_vfs *pVfs, /* VFS */
self->fd = open (self->plain_filename, oflags, 0600);
if (self->fd < 0) {
sqlite3_free (aBuf);
+ if (self->plain_filename)
+ g_free (self->plain_filename);
+ if (self->encrypted_filename)
+ g_free (self->encrypted_filename);
return SQLITE_CANTOPEN;
}
if (g_chmod (self->plain_filename, 0600) != 0 && errno != ENOENT) {
g_critical (_("Error changing database file permissions: %s"), g_strerror (errno));
sqlite3_free (aBuf);
- g_free (self->plain_filename);
- g_free (self->encrypted_filename);
+ if (self->plain_filename)
+ g_free (self->plain_filename);
+ if (self->encrypted_filename)
+ g_free (self->encrypted_filename);
close (self->fd);
return SQLITE_IOERR;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]