Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
VideoLAN
medialibrary
Commits
03cc4e1f
Commit
03cc4e1f
authored
Jan 22, 2016
by
Hugo Beauzée-Luyssen
Browse files
SqliteConnection: Fix potential leaks on error paths
parent
401b20b7
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/database/SqliteConnection.cpp
View file @
03cc4e1f
...
...
@@ -48,6 +48,7 @@ SqliteConnection::Handle SqliteConnection::getConn()
if
(
it
==
end
(
m_conns
)
)
{
auto
res
=
sqlite3_open
(
m_dbPath
.
c_str
(),
&
dbConnection
);
ConnPtr
dbConn
(
dbConnection
,
&
sqlite3_close
);
if
(
res
!=
SQLITE_OK
)
throw
std
::
runtime_error
(
"Failed to connect to database"
);
sqlite
::
Statement
s
(
dbConnection
,
"PRAGMA foreign_keys = ON"
);
...
...
@@ -58,7 +59,7 @@ SqliteConnection::Handle SqliteConnection::getConn()
s
.
execute
();
while
(
s
.
row
()
!=
nullptr
)
;
m_conns
.
emplace
(
std
::
this_thread
::
get_id
(),
ConnPtr
(
dbConnection
,
&
sqlite3_close
)
);
m_conns
.
emplace
(
std
::
this_thread
::
get_id
(),
std
::
move
(
dbConn
)
);
return
dbConnection
;
}
return
it
->
second
.
get
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment