Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
0cc05079
Commit
0cc05079
authored
Feb 26, 2019
by
Michael Meskes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hopefully fixing memory handling issues in ecpglib that Coverity found.
parent
6e52209e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
18 deletions
+19
-18
src/interfaces/ecpg/ecpglib/execute.c
src/interfaces/ecpg/ecpglib/execute.c
+19
-18
No files found.
src/interfaces/ecpg/ecpglib/execute.c
View file @
0cc05079
...
@@ -1073,9 +1073,14 @@ print_param_value(char *value, int len, int is_binary, int lineno, int nth)
...
@@ -1073,9 +1073,14 @@ print_param_value(char *value, int len, int is_binary, int lineno, int nth)
else
else
{
{
value_s
=
ecpg_alloc
(
ecpg_hex_enc_len
(
len
)
+
1
,
lineno
);
value_s
=
ecpg_alloc
(
ecpg_hex_enc_len
(
len
)
+
1
,
lineno
);
ecpg_hex_encode
(
value
,
len
,
value_s
);
if
(
value_s
!=
NULL
)
value_s
[
ecpg_hex_enc_len
(
len
)]
=
'\0'
;
{
malloced
=
true
;
ecpg_hex_encode
(
value
,
len
,
value_s
);
value_s
[
ecpg_hex_enc_len
(
len
)]
=
'\0'
;
malloced
=
true
;
}
else
value_s
=
"no memory for logging of parameter"
;
}
}
ecpg_log
(
"ecpg_free_params on line %d: parameter %d = %s
\n
"
,
ecpg_log
(
"ecpg_free_params on line %d: parameter %d = %s
\n
"
,
...
@@ -1134,7 +1139,7 @@ insert_tobeinserted(int position, int ph_len, struct statement *stmt, char *tobe
...
@@ -1134,7 +1139,7 @@ insert_tobeinserted(int position, int ph_len, struct statement *stmt, char *tobe
ecpg_free
(
stmt
->
command
);
ecpg_free
(
stmt
->
command
);
stmt
->
command
=
newcopy
;
stmt
->
command
=
newcopy
;
ecpg_free
(
(
char
*
)
tobeinserted
);
ecpg_free
(
tobeinserted
);
return
true
;
return
true
;
}
}
...
@@ -1400,6 +1405,7 @@ ecpg_build_params(struct statement *stmt)
...
@@ -1400,6 +1405,7 @@ ecpg_build_params(struct statement *stmt)
ECPG_SQLSTATE_USING_CLAUSE_DOES_NOT_MATCH_PARAMETERS
,
ECPG_SQLSTATE_USING_CLAUSE_DOES_NOT_MATCH_PARAMETERS
,
NULL
);
NULL
);
ecpg_free_params
(
stmt
,
false
);
ecpg_free_params
(
stmt
,
false
);
ecpg_free
(
tobeinserted
);
return
false
;
return
false
;
}
}
...
@@ -1436,33 +1442,28 @@ ecpg_build_params(struct statement *stmt)
...
@@ -1436,33 +1442,28 @@ ecpg_build_params(struct statement *stmt)
}
}
else
else
{
{
char
**
paramvalues
;
if
(
!
(
stmt
->
paramvalues
=
(
char
**
)
ecpg_realloc
(
stmt
->
paramvalues
,
sizeof
(
char
*
)
*
(
stmt
->
nparams
+
1
),
stmt
->
lineno
)))
int
*
paramlengths
;
int
*
paramformats
;
if
(
!
(
paramvalues
=
(
char
**
)
ecpg_realloc
(
stmt
->
paramvalues
,
sizeof
(
char
*
)
*
(
stmt
->
nparams
+
1
),
stmt
->
lineno
)))
{
{
ecpg_free_params
(
stmt
,
false
);
ecpg_free_params
(
stmt
,
false
);
ecpg_free
(
tobeinserted
);
return
false
;
return
false
;
}
}
if
(
!
(
paramlengths
=
(
int
*
)
ecpg_realloc
(
stmt
->
paramlengths
,
sizeof
(
int
)
*
(
stmt
->
nparams
+
1
),
stmt
->
lineno
)))
stmt
->
paramvalues
[
stmt
->
nparams
]
=
tobeinserted
;
if
(
!
(
stmt
->
paramlengths
=
(
int
*
)
ecpg_realloc
(
stmt
->
paramlengths
,
sizeof
(
int
)
*
(
stmt
->
nparams
+
1
),
stmt
->
lineno
)))
{
{
ecpg_free_params
(
stmt
,
false
);
ecpg_free_params
(
stmt
,
false
);
return
false
;
return
false
;
}
}
if
(
!
(
paramformats
=
(
int
*
)
ecpg_realloc
(
stmt
->
paramformats
,
sizeof
(
int
)
*
(
stmt
->
nparams
+
1
),
stmt
->
lineno
)))
stmt
->
paramlengths
[
stmt
->
nparams
]
=
binary_length
;
if
(
!
(
stmt
->
paramformats
=
(
int
*
)
ecpg_realloc
(
stmt
->
paramformats
,
sizeof
(
int
)
*
(
stmt
->
nparams
+
1
),
stmt
->
lineno
)))
{
{
ecpg_free_params
(
stmt
,
false
);
ecpg_free_params
(
stmt
,
false
);
return
false
;
return
false
;
}
}
stmt
->
paramformats
[
stmt
->
nparams
]
=
(
binary_format
?
1
:
0
);
stmt
->
nparams
++
;
stmt
->
nparams
++
;
stmt
->
paramvalues
=
paramvalues
;
stmt
->
paramlengths
=
paramlengths
;
stmt
->
paramformats
=
paramformats
;
stmt
->
paramvalues
[
stmt
->
nparams
-
1
]
=
tobeinserted
;
stmt
->
paramlengths
[
stmt
->
nparams
-
1
]
=
binary_length
;
stmt
->
paramformats
[
stmt
->
nparams
-
1
]
=
(
binary_format
?
1
:
0
);
/* let's see if this was an old style placeholder */
/* let's see if this was an old style placeholder */
if
(
stmt
->
command
[
position
]
==
'?'
)
if
(
stmt
->
command
[
position
]
==
'?'
)
...
...
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