Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
biboumi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
88
Issues
88
List
Boards
Labels
Service Desk
Milestones
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
louiz’
biboumi
Commits
c3313d0d
Commit
c3313d0d
authored
Dec 05, 2017
by
louiz’
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Always free the PGresult pointer returned by PQexec
Fix a somewhat big memory leak
parent
24dc05dd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
1 deletion
+10
-1
src/database/postgresql_engine.cpp
src/database/postgresql_engine.cpp
+6
-0
src/database/postgresql_statement.hpp
src/database/postgresql_statement.hpp
+4
-1
No files found.
src/database/postgresql_engine.cpp
View file @
c3313d0d
#include <biboumi.h>
#ifdef PQ_FOUND
#include <utils/scopeguard.hpp>
#include <database/postgresql_engine.hpp>
#include <database/postgresql_statement.hpp>
...
...
@@ -53,6 +55,10 @@ std::tuple<bool, std::string> PostgresqlEngine::raw_exec(const std::string& quer
{
log_debug
(
"raw_exec:"
,
query
);
PGresult
*
res
=
PQexec
(
this
->
conn
,
query
.
data
());
auto
sg
=
utils
::
make_scope_guard
([
res
](){
PQclear
(
res
);
});
auto
res_status
=
PQresultStatus
(
res
);
if
(
res_status
!=
PGRES_COMMAND_OK
)
return
std
::
make_tuple
(
false
,
PQresultErrorMessage
(
res
));
...
...
src/database/postgresql_statement.hpp
View file @
c3313d0d
...
...
@@ -14,7 +14,10 @@ class PostgresqlStatement: public Statement
conn
(
conn
)
{}
~
PostgresqlStatement
()
{}
{
PQclear
(
this
->
result
);
this
->
result
=
nullptr
;
}
PostgresqlStatement
(
const
PostgresqlStatement
&
)
=
delete
;
PostgresqlStatement
&
operator
=
(
const
PostgresqlStatement
&
)
=
delete
;
PostgresqlStatement
(
PostgresqlStatement
&&
other
)
=
delete
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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