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

Commit505a470

Browse files
committed
From: Erich Stamberger <eberger@gewi.kfunigraz.ac.at>
Subject: [PATCHES] oracle_compat functions core dumping on NULL-fields
1 parentd464e31 commit505a470

File tree

1 file changed

+35
-37
lines changed

1 file changed

+35
-37
lines changed

‎src/backend/utils/adt/oracle_compat.c

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Edmund Mergl <E.Mergl@bawue.de>
33
*
4-
* $Id: oracle_compat.c,v 1.5 1997/03/16 20:40:39 scrappy Exp $
4+
* $Id: oracle_compat.c,v 1.6 1997/05/07 02:46:45 scrappy Exp $
55
*
66
*/
77

@@ -42,11 +42,8 @@ lower(text *string)
4242
char*ptr,*ptr_ret;
4343
intm;
4444

45-
m=VARSIZE(string)-VARHDRSZ;
46-
47-
if (m <=0) {
45+
if ((string== (text*)NULL)|| ((m=VARSIZE(string)-VARHDRSZ) <=0))
4846
returnstring;
49-
}
5047

5148
ret= (text*)palloc(VARSIZE(string));
5249
VARSIZE(ret)=VARSIZE(string);
@@ -83,11 +80,8 @@ upper(text *string)
8380
char*ptr,*ptr_ret;
8481
intm;
8582

86-
m=VARSIZE(string)-VARHDRSZ;
87-
88-
if (m <=0) {
83+
if ((string== (text*)NULL)|| ((m=VARSIZE(string)-VARHDRSZ) <=0))
8984
returnstring;
90-
}
9185

9286
ret= (text*)palloc(VARSIZE(string));
9387
VARSIZE(ret)=VARSIZE(string);
@@ -126,11 +120,8 @@ initcap(text *string)
126120
char*ptr,*ptr_ret;
127121
intm;
128122

129-
m=VARSIZE(string)-VARHDRSZ;
130-
131-
if (m <=0) {
123+
if ((string== (text*)NULL)|| ((m=VARSIZE(string)-VARHDRSZ) <=0))
132124
returnstring;
133-
}
134125

135126
ret= (text*)palloc(VARSIZE(string));
136127
VARSIZE(ret)=VARSIZE(string);
@@ -175,11 +166,12 @@ lpad(text *string1, int4 len, text *string2)
175166
char*ptr1,*ptr2,*ptr_ret;
176167
intm,n;
177168

178-
m=len-VARSIZE(string1)+VARHDRSZ;
179-
180-
if (m <=0|| (VARSIZE(string2)-VARHDRSZ) <=0) {
169+
if ((string1== (text*)NULL)||
170+
(len <= (VARSIZE(string1)-VARHDRSZ))||
171+
((m=len-VARSIZE(string1)+VARHDRSZ) <=0)||
172+
(string2== (text*)NULL)||
173+
((VARSIZE(string2)-VARHDRSZ) <=0))
181174
returnstring1;
182-
}
183175

184176
ret= (text*)palloc(VARHDRSZ+len);
185177
VARSIZE(ret)=VARHDRSZ+len;
@@ -225,11 +217,12 @@ rpad(text *string1, int4 len, text *string2)
225217
char*ptr1,*ptr2,*ptr_ret;
226218
intm,n;
227219

228-
m=len-VARSIZE(string1)+VARHDRSZ;
229-
230-
if (m <=0|| (VARSIZE(string2)-VARHDRSZ) <=0) {
220+
if ((string1== (text*)NULL)||
221+
(len <= (VARSIZE(string1)-VARHDRSZ))||
222+
((m=len-VARSIZE(string1)+VARHDRSZ) <=0)||
223+
(string2== (text*)NULL)||
224+
((VARSIZE(string2)-VARHDRSZ) <=0))
231225
returnstring1;
232-
}
233226

234227
ret= (text*)palloc(VARHDRSZ+len);
235228
VARSIZE(ret)=VARHDRSZ+len;
@@ -275,11 +268,11 @@ ltrim(text *string, text *set)
275268
char*ptr,*ptr2,*end2,*ptr_ret;
276269
intm;
277270

278-
m=VARSIZE(string)-VARHDRSZ;
279-
280-
if (m <=0||VARSIZE(set)-VARHDRSZ <=0) {
271+
if ((string== (text*)NULL)||
272+
((m=VARSIZE(string)-VARHDRSZ) <=0)||
273+
(set== (text*)NULL)||
274+
((VARSIZE(set)-VARHDRSZ) <=0))
281275
returnstring;
282-
}
283276

284277
ptr=VARDATA(string);
285278
ptr2=VARDATA(set);
@@ -336,11 +329,11 @@ rtrim(text *string, text *set)
336329
char*ptr,*ptr2,*end2,*ptr_ret;
337330
intm;
338331

339-
m=VARSIZE(string)-VARHDRSZ;
340-
341-
if (m <=0||VARSIZE(set)-VARHDRSZ <=0) {
332+
if ((string== (text*)NULL)||
333+
((m=VARSIZE(string)-VARHDRSZ) <=0)||
334+
(set== (text*)NULL)||
335+
((VARSIZE(set)-VARHDRSZ) <=0))
342336
returnstring;
343-
}
344337

345338
ptr=VARDATA(string)+VARSIZE(string)-VARHDRSZ-1;
346339
ptr2=VARDATA(set);
@@ -397,11 +390,10 @@ substr(text *string, int4 m, int4 n)
397390
char*ptr,*ptr_ret;
398391
intlen;
399392

400-
len=VARSIZE(string)-VARHDRSZ-m;
401-
402-
if (m <=0||n <=0||len<=0) {
393+
if ((string== (text*)NULL)||
394+
(m <=0)|| (n <=0)||
395+
((len=VARSIZE(string)-VARHDRSZ-m)<=0))
403396
returnstring;
404-
}
405397

406398
len=len+1<n ?len+1 :n;
407399

@@ -442,11 +434,9 @@ translate(text *string, char from, char to)
442434
char*ptr,*ptr_ret;
443435
intm;
444436

445-
m=VARSIZE(string)-VARHDRSZ;
446-
447-
if (m <=0) {
437+
if ((string== (text*)NULL)||
438+
((m=VARSIZE(string)-VARHDRSZ) <=0))
448439
returnstring;
449-
}
450440

451441
ret= (text*)palloc(VARSIZE(string));
452442
VARSIZE(ret)=VARSIZE(string);
@@ -464,3 +454,11 @@ translate(text *string, char from, char to)
464454

465455

466456
/* EOF */
457+
458+
459+
460+
461+
462+
463+
464+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp