Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
942b6319
Commit
942b6319
authored
13 years ago
by
Peter Eisentraut
Browse files
Options
Downloads
Patches
Plain Diff
Add missing va_end() calls
found by Coverity
parent
6f018c6d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/interfaces/ecpg/ecpglib/descriptor.c
+54
-0
54 additions, 0 deletions
src/interfaces/ecpg/ecpglib/descriptor.c
with
54 additions
and
0 deletions
src/interfaces/ecpg/ecpglib/descriptor.c
+
54
−
0
View file @
942b6319
...
@@ -229,6 +229,7 @@ get_char_item(int lineno, void *var, enum ECPGttype vartype, char *value, int va
...
@@ -229,6 +229,7 @@ get_char_item(int lineno, void *var, enum ECPGttype vartype, char *value, int va
#define RETURN_IF_NO_DATA if (ntuples < 1) \
#define RETURN_IF_NO_DATA if (ntuples < 1) \
{ \
{ \
va_end(args); \
ecpg_raise(lineno, ECPG_NOT_FOUND, ECPG_SQLSTATE_NO_DATA, NULL); \
ecpg_raise(lineno, ECPG_NOT_FOUND, ECPG_SQLSTATE_NO_DATA, NULL); \
return (false); \
return (false); \
}
}
...
@@ -248,13 +249,17 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
...
@@ -248,13 +249,17 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
ecpg_init_sqlca
(
sqlca
);
ecpg_init_sqlca
(
sqlca
);
ECPGresult
=
ecpg_result_by_descriptor
(
lineno
,
desc_name
);
ECPGresult
=
ecpg_result_by_descriptor
(
lineno
,
desc_name
);
if
(
!
ECPGresult
)
if
(
!
ECPGresult
)
{
va_end
(
args
);
return
(
false
);
return
(
false
);
}
ntuples
=
PQntuples
(
ECPGresult
);
ntuples
=
PQntuples
(
ECPGresult
);
if
(
index
<
1
||
index
>
PQnfields
(
ECPGresult
))
if
(
index
<
1
||
index
>
PQnfields
(
ECPGresult
))
{
{
ecpg_raise
(
lineno
,
ECPG_INVALID_DESCRIPTOR_INDEX
,
ECPG_SQLSTATE_INVALID_DESCRIPTOR_INDEX
,
NULL
);
ecpg_raise
(
lineno
,
ECPG_INVALID_DESCRIPTOR_INDEX
,
ECPG_SQLSTATE_INVALID_DESCRIPTOR_INDEX
,
NULL
);
va_end
(
args
);
return
(
false
);
return
(
false
);
}
}
...
@@ -312,68 +317,98 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
...
@@ -312,68 +317,98 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
case
ECPGd_name
:
case
ECPGd_name
:
if
(
!
get_char_item
(
lineno
,
var
,
vartype
,
PQfname
(
ECPGresult
,
index
),
varcharsize
))
if
(
!
get_char_item
(
lineno
,
var
,
vartype
,
PQfname
(
ECPGresult
,
index
),
varcharsize
))
{
va_end
(
args
);
return
(
false
);
return
(
false
);
}
ecpg_log
(
"ECPGget_desc: NAME = %s
\n
"
,
PQfname
(
ECPGresult
,
index
));
ecpg_log
(
"ECPGget_desc: NAME = %s
\n
"
,
PQfname
(
ECPGresult
,
index
));
break
;
break
;
case
ECPGd_nullable
:
case
ECPGd_nullable
:
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
1
))
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
1
))
{
va_end
(
args
);
return
(
false
);
return
(
false
);
}
break
;
break
;
case
ECPGd_key_member
:
case
ECPGd_key_member
:
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
0
))
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
0
))
{
va_end
(
args
);
return
(
false
);
return
(
false
);
}
break
;
break
;
case
ECPGd_scale
:
case
ECPGd_scale
:
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
(
PQfmod
(
ECPGresult
,
index
)
-
VARHDRSZ
)
&
0xffff
))
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
(
PQfmod
(
ECPGresult
,
index
)
-
VARHDRSZ
)
&
0xffff
))
{
va_end
(
args
);
return
(
false
);
return
(
false
);
}
ecpg_log
(
"ECPGget_desc: SCALE = %d
\n
"
,
(
PQfmod
(
ECPGresult
,
index
)
-
VARHDRSZ
)
&
0xffff
);
ecpg_log
(
"ECPGget_desc: SCALE = %d
\n
"
,
(
PQfmod
(
ECPGresult
,
index
)
-
VARHDRSZ
)
&
0xffff
);
break
;
break
;
case
ECPGd_precision
:
case
ECPGd_precision
:
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
PQfmod
(
ECPGresult
,
index
)
>>
16
))
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
PQfmod
(
ECPGresult
,
index
)
>>
16
))
{
va_end
(
args
);
return
(
false
);
return
(
false
);
}
ecpg_log
(
"ECPGget_desc: PRECISION = %d
\n
"
,
PQfmod
(
ECPGresult
,
index
)
>>
16
);
ecpg_log
(
"ECPGget_desc: PRECISION = %d
\n
"
,
PQfmod
(
ECPGresult
,
index
)
>>
16
);
break
;
break
;
case
ECPGd_octet
:
case
ECPGd_octet
:
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
PQfsize
(
ECPGresult
,
index
)))
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
PQfsize
(
ECPGresult
,
index
)))
{
va_end
(
args
);
return
(
false
);
return
(
false
);
}
ecpg_log
(
"ECPGget_desc: OCTET_LENGTH = %d
\n
"
,
PQfsize
(
ECPGresult
,
index
));
ecpg_log
(
"ECPGget_desc: OCTET_LENGTH = %d
\n
"
,
PQfsize
(
ECPGresult
,
index
));
break
;
break
;
case
ECPGd_length
:
case
ECPGd_length
:
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
PQfmod
(
ECPGresult
,
index
)
-
VARHDRSZ
))
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
PQfmod
(
ECPGresult
,
index
)
-
VARHDRSZ
))
{
va_end
(
args
);
return
(
false
);
return
(
false
);
}
ecpg_log
(
"ECPGget_desc: LENGTH = %d
\n
"
,
PQfmod
(
ECPGresult
,
index
)
-
VARHDRSZ
);
ecpg_log
(
"ECPGget_desc: LENGTH = %d
\n
"
,
PQfmod
(
ECPGresult
,
index
)
-
VARHDRSZ
);
break
;
break
;
case
ECPGd_type
:
case
ECPGd_type
:
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
ecpg_dynamic_type
(
PQftype
(
ECPGresult
,
index
))))
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
ecpg_dynamic_type
(
PQftype
(
ECPGresult
,
index
))))
{
va_end
(
args
);
return
(
false
);
return
(
false
);
}
ecpg_log
(
"ECPGget_desc: TYPE = %d
\n
"
,
ecpg_dynamic_type
(
PQftype
(
ECPGresult
,
index
)));
ecpg_log
(
"ECPGget_desc: TYPE = %d
\n
"
,
ecpg_dynamic_type
(
PQftype
(
ECPGresult
,
index
)));
break
;
break
;
case
ECPGd_di_code
:
case
ECPGd_di_code
:
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
ecpg_dynamic_type_DDT
(
PQftype
(
ECPGresult
,
index
))))
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
ecpg_dynamic_type_DDT
(
PQftype
(
ECPGresult
,
index
))))
{
va_end
(
args
);
return
(
false
);
return
(
false
);
}
ecpg_log
(
"ECPGget_desc: TYPE = %d
\n
"
,
ecpg_dynamic_type_DDT
(
PQftype
(
ECPGresult
,
index
)));
ecpg_log
(
"ECPGget_desc: TYPE = %d
\n
"
,
ecpg_dynamic_type_DDT
(
PQftype
(
ECPGresult
,
index
)));
break
;
break
;
case
ECPGd_cardinality
:
case
ECPGd_cardinality
:
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
PQntuples
(
ECPGresult
)))
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
PQntuples
(
ECPGresult
)))
{
va_end
(
args
);
return
(
false
);
return
(
false
);
}
ecpg_log
(
"ECPGget_desc: CARDINALITY = %d
\n
"
,
PQntuples
(
ECPGresult
));
ecpg_log
(
"ECPGget_desc: CARDINALITY = %d
\n
"
,
PQntuples
(
ECPGresult
));
break
;
break
;
...
@@ -391,6 +426,7 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
...
@@ -391,6 +426,7 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
ecpg_log
(
"ECPGget_desc on line %d: incorrect number of matches; %d don't fit into array of %ld
\n
"
,
ecpg_log
(
"ECPGget_desc on line %d: incorrect number of matches; %d don't fit into array of %ld
\n
"
,
lineno
,
ntuples
,
arrsize
);
lineno
,
ntuples
,
arrsize
);
ecpg_raise
(
lineno
,
ECPG_TOO_MANY_MATCHES
,
ECPG_SQLSTATE_CARDINALITY_VIOLATION
,
NULL
);
ecpg_raise
(
lineno
,
ECPG_TOO_MANY_MATCHES
,
ECPG_SQLSTATE_CARDINALITY_VIOLATION
,
NULL
);
va_end
(
args
);
return
false
;
return
false
;
}
}
/* allocate storage if needed */
/* allocate storage if needed */
...
@@ -399,7 +435,10 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
...
@@ -399,7 +435,10 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
void
*
mem
=
(
void
*
)
ecpg_alloc
(
offset
*
ntuples
,
lineno
);
void
*
mem
=
(
void
*
)
ecpg_alloc
(
offset
*
ntuples
,
lineno
);
if
(
!
mem
)
if
(
!
mem
)
{
va_end
(
args
);
return
false
;
return
false
;
}
*
(
void
**
)
var
=
mem
;
*
(
void
**
)
var
=
mem
;
ecpg_add_mem
(
mem
,
lineno
);
ecpg_add_mem
(
mem
,
lineno
);
var
=
mem
;
var
=
mem
;
...
@@ -408,7 +447,10 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
...
@@ -408,7 +447,10 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
for
(
act_tuple
=
0
;
act_tuple
<
ntuples
;
act_tuple
++
)
for
(
act_tuple
=
0
;
act_tuple
<
ntuples
;
act_tuple
++
)
{
{
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
PQgetlength
(
ECPGresult
,
act_tuple
,
index
)))
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
PQgetlength
(
ECPGresult
,
act_tuple
,
index
)))
{
va_end
(
args
);
return
(
false
);
return
(
false
);
}
var
=
(
char
*
)
var
+
offset
;
var
=
(
char
*
)
var
+
offset
;
ecpg_log
(
"ECPGget_desc: RETURNED[%d] = %d
\n
"
,
act_tuple
,
PQgetlength
(
ECPGresult
,
act_tuple
,
index
));
ecpg_log
(
"ECPGget_desc: RETURNED[%d] = %d
\n
"
,
act_tuple
,
PQgetlength
(
ECPGresult
,
act_tuple
,
index
));
}
}
...
@@ -417,6 +459,7 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
...
@@ -417,6 +459,7 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
default:
default:
snprintf
(
type_str
,
sizeof
(
type_str
),
"%d"
,
type
);
snprintf
(
type_str
,
sizeof
(
type_str
),
"%d"
,
type
);
ecpg_raise
(
lineno
,
ECPG_UNKNOWN_DESCRIPTOR_ITEM
,
ECPG_SQLSTATE_ECPG_INTERNAL_ERROR
,
type_str
);
ecpg_raise
(
lineno
,
ECPG_UNKNOWN_DESCRIPTOR_ITEM
,
ECPG_SQLSTATE_ECPG_INTERNAL_ERROR
,
type_str
);
va_end
(
args
);
return
(
false
);
return
(
false
);
}
}
...
@@ -460,6 +503,7 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
...
@@ -460,6 +503,7 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
ecpg_log
(
"ECPGget_desc on line %d: incorrect number of matches (indicator); %d don't fit into array of %ld
\n
"
,
ecpg_log
(
"ECPGget_desc on line %d: incorrect number of matches (indicator); %d don't fit into array of %ld
\n
"
,
lineno
,
ntuples
,
data_var
.
ind_arrsize
);
lineno
,
ntuples
,
data_var
.
ind_arrsize
);
ecpg_raise
(
lineno
,
ECPG_TOO_MANY_MATCHES
,
ECPG_SQLSTATE_CARDINALITY_VIOLATION
,
NULL
);
ecpg_raise
(
lineno
,
ECPG_TOO_MANY_MATCHES
,
ECPG_SQLSTATE_CARDINALITY_VIOLATION
,
NULL
);
va_end
(
args
);
return
false
;
return
false
;
}
}
...
@@ -469,7 +513,10 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
...
@@ -469,7 +513,10 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
void
*
mem
=
(
void
*
)
ecpg_alloc
(
data_var
.
ind_offset
*
ntuples
,
lineno
);
void
*
mem
=
(
void
*
)
ecpg_alloc
(
data_var
.
ind_offset
*
ntuples
,
lineno
);
if
(
!
mem
)
if
(
!
mem
)
{
va_end
(
args
);
return
false
;
return
false
;
}
*
(
void
**
)
data_var
.
ind_pointer
=
mem
;
*
(
void
**
)
data_var
.
ind_pointer
=
mem
;
ecpg_add_mem
(
mem
,
lineno
);
ecpg_add_mem
(
mem
,
lineno
);
data_var
.
ind_value
=
mem
;
data_var
.
ind_value
=
mem
;
...
@@ -478,12 +525,16 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
...
@@ -478,12 +525,16 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
for
(
act_tuple
=
0
;
act_tuple
<
ntuples
;
act_tuple
++
)
for
(
act_tuple
=
0
;
act_tuple
<
ntuples
;
act_tuple
++
)
{
{
if
(
!
get_int_item
(
lineno
,
data_var
.
ind_value
,
data_var
.
ind_type
,
-
PQgetisnull
(
ECPGresult
,
act_tuple
,
index
)))
if
(
!
get_int_item
(
lineno
,
data_var
.
ind_value
,
data_var
.
ind_type
,
-
PQgetisnull
(
ECPGresult
,
act_tuple
,
index
)))
{
va_end
(
args
);
return
(
false
);
return
(
false
);
}
data_var
.
ind_value
=
(
char
*
)
data_var
.
ind_value
+
data_var
.
ind_offset
;
data_var
.
ind_value
=
(
char
*
)
data_var
.
ind_value
+
data_var
.
ind_offset
;
ecpg_log
(
"ECPGget_desc: INDICATOR[%d] = %d
\n
"
,
act_tuple
,
-
PQgetisnull
(
ECPGresult
,
act_tuple
,
index
));
ecpg_log
(
"ECPGget_desc: INDICATOR[%d] = %d
\n
"
,
act_tuple
,
-
PQgetisnull
(
ECPGresult
,
act_tuple
,
index
));
}
}
}
}
sqlca
->
sqlerrd
[
2
]
=
ntuples
;
sqlca
->
sqlerrd
[
2
]
=
ntuples
;
va_end
(
args
);
return
(
true
);
return
(
true
);
}
}
...
@@ -575,6 +626,7 @@ ECPGset_desc(int lineno, const char *desc_name, int index,...)
...
@@ -575,6 +626,7 @@ ECPGset_desc(int lineno, const char *desc_name, int index,...)
if
(
!
ecpg_store_input
(
lineno
,
true
,
var
,
&
tobeinserted
,
false
))
if
(
!
ecpg_store_input
(
lineno
,
true
,
var
,
&
tobeinserted
,
false
))
{
{
ecpg_free
(
var
);
ecpg_free
(
var
);
va_end
(
args
);
return
false
;
return
false
;
}
}
...
@@ -612,11 +664,13 @@ ECPGset_desc(int lineno, const char *desc_name, int index,...)
...
@@ -612,11 +664,13 @@ ECPGset_desc(int lineno, const char *desc_name, int index,...)
snprintf
(
type_str
,
sizeof
(
type_str
),
"%d"
,
itemtype
);
snprintf
(
type_str
,
sizeof
(
type_str
),
"%d"
,
itemtype
);
ecpg_raise
(
lineno
,
ECPG_UNKNOWN_DESCRIPTOR_ITEM
,
ECPG_SQLSTATE_ECPG_INTERNAL_ERROR
,
type_str
);
ecpg_raise
(
lineno
,
ECPG_UNKNOWN_DESCRIPTOR_ITEM
,
ECPG_SQLSTATE_ECPG_INTERNAL_ERROR
,
type_str
);
ecpg_free
(
var
);
ecpg_free
(
var
);
va_end
(
args
);
return
false
;
return
false
;
}
}
}
}
}
}
ecpg_free
(
var
);
ecpg_free
(
var
);
va_end
(
args
);
return
true
;
return
true
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment