Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit956cbeb

Browse files
author
Michael Meskes
committed
Fixed remaining Coverity bugs.
1 parent2d0c1d3 commit956cbeb

File tree

3 files changed

+30
-10
lines changed

3 files changed

+30
-10
lines changed

‎src/interfaces/ecpg/ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2040,5 +2040,9 @@ Mo Jun 26 16:08:23 CEST 2006
20402040

20412041
- Added missing braces to prevent a segfault after usage of an
20422042
undeclared cursor.
2043+
2044+
We Jul 5 12:17:28 CEST 2006
2045+
2046+
- Fixed remaining Coverity bugs.
20432047
- Set ecpg library version to 5.2.
20442048
- Set ecpg version to 4.2.1.

‎src/interfaces/ecpg/ecpglib/descriptor.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* dynamic SQL support routines
22
*
3-
* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v 1.16 2006/06/25 09:38:39 meskes Exp $
3+
* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v 1.17 2006/07/05 10:49:56 meskes Exp $
44
*/
55

66
#definePOSTGRES_ECPG_INTERNAL
@@ -249,7 +249,7 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
249249
data_var.ind_varcharsize=varcharsize;
250250
data_var.ind_arrsize=arrsize;
251251
data_var.ind_offset=offset;
252-
if (data_var.ind_arrsize==0||data_var.ind_varcharsize==0)
252+
if ((data_var.ind_arrsize==0||data_var.ind_varcharsize==0)&&data_var.ind_pointer!=NULL)
253253
data_var.ind_value=*((void**) (data_var.ind_pointer));
254254
else
255255
data_var.ind_value=data_var.ind_pointer;
@@ -397,7 +397,8 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
397397
setlocale(LC_NUMERIC,oldlocale);
398398
ECPGfree(oldlocale);
399399
}
400-
elseif (data_var.ind_type!=ECPGt_NO_INDICATOR)
400+
elseif (data_var.ind_type!=ECPGt_NO_INDICATOR&&data_var.ind_pointer!=NULL)
401+
/* ind_type != NO_INDICATOR should always have ind_pointer != NULL but since this might be changed manually in the .c file let's play it safe */
401402
{
402403
/*
403404
* this is like ECPGstore_result but since we don't have a data
@@ -410,8 +411,9 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
410411
ECPGraise(lineno,ECPG_TOO_MANY_MATCHES,ECPG_SQLSTATE_CARDINALITY_VIOLATION,NULL);
411412
return false;
412413
}
414+
413415
/* allocate storage if needed */
414-
if (data_var.ind_arrsize==0&&data_var.ind_pointer!=NULL&&data_var.ind_value==NULL)
416+
if (data_var.ind_arrsize==0&&data_var.ind_value==NULL)
415417
{
416418
void*mem= (void*)ECPGalloc(data_var.ind_offset*ntuples,lineno);
417419
if (!mem)
@@ -420,6 +422,7 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
420422
ECPGadd_mem(mem,lineno);
421423
data_var.ind_value=mem;
422424
}
425+
423426
for (act_tuple=0;act_tuple<ntuples;act_tuple++)
424427
{
425428
if (!get_int_item(lineno,data_var.ind_value,data_var.ind_type,-PQgetisnull(ECPGresult,act_tuple,index)))

‎src/interfaces/ecpg/ecpglib/execute.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.50 2006/06/26 09:20:09 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.51 2006/07/05 10:49:56 meskes Exp $ */
22

33
/*
44
* The aim is to get a simpler inteface to the database routines.
@@ -876,12 +876,13 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
876876
{
877877
char*str=NULL;
878878
intslen;
879-
numeric*nval=PGTYPESnumeric_new();
879+
numeric*nval;
880880

881881
if (var->arrsize>1)
882882
{
883-
for (element=0;element<var->arrsize;element++,nval=PGTYPESnumeric_new())
883+
for (element=0;element<var->arrsize;element++)
884884
{
885+
nval=PGTYPESnumeric_new();
885886
if (!nval)
886887
return false;
887888

@@ -911,6 +912,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
911912
}
912913
else
913914
{
915+
nval=PGTYPESnumeric_new();
914916
if (!nval)
915917
return false;
916918

@@ -1048,16 +1050,22 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
10481050

10491051
caseECPGt_timestamp:
10501052
{
1051-
char*str=NULL;
1053+
char*str=NULL,*asc=NULL;
10521054
intslen;
10531055

10541056
if (var->arrsize>1)
10551057
{
10561058
for (element=0;element<var->arrsize;element++)
10571059
{
1058-
str=quote_postgres(PGTYPEStimestamp_to_asc(*(timestamp*) ((var+var->offset*element)->value)),lineno);
1060+
asc=PGTYPEStimestamp_to_asc(*(timestamp*) ((var+var->offset*element)->value));
1061+
if (!asc)
1062+
return false;
1063+
1064+
str=quote_postgres(asc,lineno);
1065+
ECPGfree(asc);/* we don't need this anymore so free it asap. */
10591066
if (!str)
10601067
return false;
1068+
10611069
slen=strlen(str);
10621070

10631071
if (!(mallocedval=ECPGrealloc(mallocedval,strlen(mallocedval)+slen+sizeof("array [], timestamp "),lineno)))
@@ -1077,7 +1085,12 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
10771085
}
10781086
else
10791087
{
1080-
str=quote_postgres(PGTYPEStimestamp_to_asc(*(timestamp*) (var->value)),lineno);
1088+
asc=PGTYPEStimestamp_to_asc(*(timestamp*) (var->value));
1089+
if (!asc)
1090+
return false;
1091+
1092+
str=quote_postgres(asc,lineno);
1093+
ECPGfree(asc);/* we don't need this anymore so free it asap. */
10811094
if (!str)
10821095
return false;
10831096
slen=strlen(str);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp