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
942b6319
Commit
942b6319
authored
Mar 14, 2012
by
Peter Eisentraut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add missing va_end() calls
found by Coverity
parent
6f018c6d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
0 deletions
+54
-0
src/interfaces/ecpg/ecpglib/descriptor.c
src/interfaces/ecpg/ecpglib/descriptor.c
+54
-0
No files found.
src/interfaces/ecpg/ecpglib/descriptor.c
View file @
942b6319
...
...
@@ -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) \
{ \
va_end(args); \
ecpg_raise(lineno, ECPG_NOT_FOUND, ECPG_SQLSTATE_NO_DATA, NULL); \
return (false); \
}
...
...
@@ -248,13 +249,17 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
ecpg_init_sqlca
(
sqlca
);
ECPGresult
=
ecpg_result_by_descriptor
(
lineno
,
desc_name
);
if
(
!
ECPGresult
)
{
va_end
(
args
);
return
(
false
);
}
ntuples
=
PQntuples
(
ECPGresult
);
if
(
index
<
1
||
index
>
PQnfields
(
ECPGresult
))
{
ecpg_raise
(
lineno
,
ECPG_INVALID_DESCRIPTOR_INDEX
,
ECPG_SQLSTATE_INVALID_DESCRIPTOR_INDEX
,
NULL
);
va_end
(
args
);
return
(
false
);
}
...
...
@@ -312,68 +317,98 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
case
ECPGd_name
:
if
(
!
get_char_item
(
lineno
,
var
,
vartype
,
PQfname
(
ECPGresult
,
index
),
varcharsize
))
{
va_end
(
args
);
return
(
false
);
}
ecpg_log
(
"ECPGget_desc: NAME = %s
\n
"
,
PQfname
(
ECPGresult
,
index
));
break
;
case
ECPGd_nullable
:
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
1
))
{
va_end
(
args
);
return
(
false
);
}
break
;
case
ECPGd_key_member
:
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
0
))
{
va_end
(
args
);
return
(
false
);
}
break
;
case
ECPGd_scale
:
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
(
PQfmod
(
ECPGresult
,
index
)
-
VARHDRSZ
)
&
0xffff
))
{
va_end
(
args
);
return
(
false
);
}
ecpg_log
(
"ECPGget_desc: SCALE = %d
\n
"
,
(
PQfmod
(
ECPGresult
,
index
)
-
VARHDRSZ
)
&
0xffff
);
break
;
case
ECPGd_precision
:
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
PQfmod
(
ECPGresult
,
index
)
>>
16
))
{
va_end
(
args
);
return
(
false
);
}
ecpg_log
(
"ECPGget_desc: PRECISION = %d
\n
"
,
PQfmod
(
ECPGresult
,
index
)
>>
16
);
break
;
case
ECPGd_octet
:
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
PQfsize
(
ECPGresult
,
index
)))
{
va_end
(
args
);
return
(
false
);
}
ecpg_log
(
"ECPGget_desc: OCTET_LENGTH = %d
\n
"
,
PQfsize
(
ECPGresult
,
index
));
break
;
case
ECPGd_length
:
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
PQfmod
(
ECPGresult
,
index
)
-
VARHDRSZ
))
{
va_end
(
args
);
return
(
false
);
}
ecpg_log
(
"ECPGget_desc: LENGTH = %d
\n
"
,
PQfmod
(
ECPGresult
,
index
)
-
VARHDRSZ
);
break
;
case
ECPGd_type
:
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
ecpg_dynamic_type
(
PQftype
(
ECPGresult
,
index
))))
{
va_end
(
args
);
return
(
false
);
}
ecpg_log
(
"ECPGget_desc: TYPE = %d
\n
"
,
ecpg_dynamic_type
(
PQftype
(
ECPGresult
,
index
)));
break
;
case
ECPGd_di_code
:
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
ecpg_dynamic_type_DDT
(
PQftype
(
ECPGresult
,
index
))))
{
va_end
(
args
);
return
(
false
);
}
ecpg_log
(
"ECPGget_desc: TYPE = %d
\n
"
,
ecpg_dynamic_type_DDT
(
PQftype
(
ECPGresult
,
index
)));
break
;
case
ECPGd_cardinality
:
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
PQntuples
(
ECPGresult
)))
{
va_end
(
args
);
return
(
false
);
}
ecpg_log
(
"ECPGget_desc: CARDINALITY = %d
\n
"
,
PQntuples
(
ECPGresult
));
break
;
...
...
@@ -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
"
,
lineno
,
ntuples
,
arrsize
);
ecpg_raise
(
lineno
,
ECPG_TOO_MANY_MATCHES
,
ECPG_SQLSTATE_CARDINALITY_VIOLATION
,
NULL
);
va_end
(
args
);
return
false
;
}
/* allocate storage if needed */
...
...
@@ -399,7 +435,10 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
void
*
mem
=
(
void
*
)
ecpg_alloc
(
offset
*
ntuples
,
lineno
);
if
(
!
mem
)
{
va_end
(
args
);
return
false
;
}
*
(
void
**
)
var
=
mem
;
ecpg_add_mem
(
mem
,
lineno
);
var
=
mem
;
...
...
@@ -408,7 +447,10 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
for
(
act_tuple
=
0
;
act_tuple
<
ntuples
;
act_tuple
++
)
{
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
PQgetlength
(
ECPGresult
,
act_tuple
,
index
)))
{
va_end
(
args
);
return
(
false
);
}
var
=
(
char
*
)
var
+
offset
;
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,...)
default:
snprintf
(
type_str
,
sizeof
(
type_str
),
"%d"
,
type
);
ecpg_raise
(
lineno
,
ECPG_UNKNOWN_DESCRIPTOR_ITEM
,
ECPG_SQLSTATE_ECPG_INTERNAL_ERROR
,
type_str
);
va_end
(
args
);
return
(
false
);
}
...
...
@@ -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
"
,
lineno
,
ntuples
,
data_var
.
ind_arrsize
);
ecpg_raise
(
lineno
,
ECPG_TOO_MANY_MATCHES
,
ECPG_SQLSTATE_CARDINALITY_VIOLATION
,
NULL
);
va_end
(
args
);
return
false
;
}
...
...
@@ -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
);
if
(
!
mem
)
{
va_end
(
args
);
return
false
;
}
*
(
void
**
)
data_var
.
ind_pointer
=
mem
;
ecpg_add_mem
(
mem
,
lineno
);
data_var
.
ind_value
=
mem
;
...
...
@@ -478,12 +525,16 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
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
)))
{
va_end
(
args
);
return
(
false
);
}
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
));
}
}
sqlca
->
sqlerrd
[
2
]
=
ntuples
;
va_end
(
args
);
return
(
true
);
}
...
...
@@ -575,6 +626,7 @@ ECPGset_desc(int lineno, const char *desc_name, int index,...)
if
(
!
ecpg_store_input
(
lineno
,
true
,
var
,
&
tobeinserted
,
false
))
{
ecpg_free
(
var
);
va_end
(
args
);
return
false
;
}
...
...
@@ -612,11 +664,13 @@ ECPGset_desc(int lineno, const char *desc_name, int index,...)
snprintf
(
type_str
,
sizeof
(
type_str
),
"%d"
,
itemtype
);
ecpg_raise
(
lineno
,
ECPG_UNKNOWN_DESCRIPTOR_ITEM
,
ECPG_SQLSTATE_ECPG_INTERNAL_ERROR
,
type_str
);
ecpg_free
(
var
);
va_end
(
args
);
return
false
;
}
}
}
ecpg_free
(
var
);
va_end
(
args
);
return
true
;
}
...
...
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