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

Commit76b45c9

Browse files
author
Michael Meskes
committed
Informix fixes.
1 parentda2060e commit76b45c9

File tree

1 file changed

+68
-11
lines changed

1 file changed

+68
-11
lines changed

‎src/interfaces/ecpg/compatlib/informix.c

Lines changed: 68 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,30 @@
1111
int
1212
decadd(Numeric*arg1,Numeric*arg2,Numeric*sum)
1313
{
14-
inti=PGTYPESnumeric_add(arg1,arg2,sum);
14+
Numeric*temp_sum=malloc(sizeof(Numeric)) ;
15+
inti;
16+
17+
if (temp_sum==NULL)
18+
return-1211;
19+
20+
i=PGTYPESnumeric_add(arg1,arg2,temp_sum);
1521

1622
if (i==0)/* No error */
23+
{
24+
25+
if (PGTYPESnumeric_copy(temp_sum,sum)!=0)
26+
return-1211;
27+
28+
free(temp_sum);
1729
return0;
18-
if (errno==PGTYPES_NUM_OVERFLOW)
19-
return-1200;
30+
}
31+
else
32+
{
33+
free(temp_sum);
34+
35+
if (errno==PGTYPES_NUM_OVERFLOW)
36+
return-1200;
37+
}
2038

2139
return-1201;
2240
}
@@ -26,7 +44,6 @@ deccmp(Numeric *arg1, Numeric *arg2)
2644
{
2745
inti=PGTYPESnumeric_cmp(arg1,arg2);
2846

29-
/* TODO: Need to return DECUNKNOWN instead of PGTYPES_NUM_BAD_NUMERIC */
3047
return (i);
3148
}
3249

@@ -46,7 +63,7 @@ strndup(char *str, int len)
4663

4764
if (new)
4865
{
49-
memcpy(str,new,use_len);
66+
memcpy(new,str,use_len);
5067
new[use_len]='\0';
5168
}
5269
else
@@ -60,13 +77,14 @@ deccvasc(char *cp, int len, Numeric *np)
6077
{
6178
char*str=strndup(cp,len);/* Numeric_in always converts the complete string */
6279
intret=0;
80+
Numeric*result;
6381

6482
if (!str)
6583
ret=-1201;
6684
else
6785
{
68-
np=PGTYPESnumeric_from_asc(str,NULL);
69-
if (!np)
86+
result=PGTYPESnumeric_from_asc(str,NULL);
87+
if (!result)
7088
{
7189
switch (errno)
7290
{
@@ -78,6 +96,13 @@ deccvasc(char *cp, int len, Numeric *np)
7896
break;
7997
}
8098
}
99+
else
100+
{
101+
if (PGTYPESnumeric_copy(result,np)!=0)
102+
ret=-1211;
103+
104+
free(result);
105+
}
81106
}
82107

83108
returnret;
@@ -104,7 +129,13 @@ deccvlong(long lng, Numeric *np)
104129
int
105130
decdiv(Numeric*n1,Numeric*n2,Numeric*n3)
106131
{
107-
inti=PGTYPESnumeric_div(n1,n2,n3),ret=0;
132+
Numeric*temp=malloc(sizeof(Numeric));
133+
inti,ret=0;
134+
135+
if (temp==NULL)
136+
return-1211;
137+
138+
i=PGTYPESnumeric_div(n1,n2,temp);
108139

109140
if (i!=0)
110141
switch (errno)
@@ -116,14 +147,24 @@ decdiv(Numeric *n1, Numeric *n2, Numeric *n3)
116147
default:ret=-1201;
117148
break;
118149
}
119-
150+
else
151+
if (PGTYPESnumeric_copy(temp,n3)!=0)
152+
ret=-1211;
153+
154+
free(temp);
120155
returnret;
121156
}
122157

123158
int
124159
decmul(Numeric*n1,Numeric*n2,Numeric*n3)
125160
{
126-
inti=PGTYPESnumeric_mul(n1,n2,n3),ret=0;
161+
Numeric*temp=malloc(sizeof(Numeric));
162+
inti,ret=0;
163+
164+
if (temp==NULL)
165+
return-1211;
166+
167+
i=PGTYPESnumeric_mul(n1,n2,temp);
127168

128169
if (i!=0)
129170
switch (errno)
@@ -133,14 +174,25 @@ decmul(Numeric *n1, Numeric *n2, Numeric *n3)
133174
default:ret=-1201;
134175
break;
135176
}
177+
else
178+
if (PGTYPESnumeric_copy(temp,n3)!=0)
179+
ret=-1211;
180+
181+
free(temp);
136182

137183
returnret;
138184
}
139185

140186
int
141187
decsub(Numeric*n1,Numeric*n2,Numeric*n3)
142188
{
143-
inti=PGTYPESnumeric_sub(n1,n2,n3),ret=0;
189+
Numeric*temp=malloc(sizeof(Numeric));
190+
inti,ret=0;
191+
192+
if (temp==NULL)
193+
return-1211;
194+
195+
i=PGTYPESnumeric_sub(n1,n2,temp);
144196

145197
if (i!=0)
146198
switch (errno)
@@ -150,6 +202,11 @@ decsub(Numeric *n1, Numeric *n2, Numeric *n3)
150202
default:ret=-1201;
151203
break;
152204
}
205+
else
206+
if (PGTYPESnumeric_copy(temp,n3)!=0)
207+
ret=-1211;
208+
209+
free(temp);
153210

154211
returnret;
155212
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp