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

Commit12449f1

Browse files
committed
ltree: Zero padding bytes when allocating memory for externally visible data.
ltree/ltree_gist/ltxtquery's headers stores data at MAXALIGN alignment,requiring some padding bytes. So far we left these uninitialized. Zerothose by using palloc0.Author: Andres FreundReported-By: Andres Freund / valgrind / buildarm animal skinkBackpatch: 9.1-
1 parent44f9f1f commit12449f1

File tree

5 files changed

+20
-20
lines changed

5 files changed

+20
-20
lines changed

‎contrib/ltree/_ltree_gist.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ _ltree_compress(PG_FUNCTION_ARGS)
9696
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
9797
errmsg("array must not contain nulls")));
9898

99-
key= (ltree_gist*)palloc(len);
99+
key= (ltree_gist*)palloc0(len);
100100
SET_VARSIZE(key,len);
101101
key->flag=0;
102102

@@ -127,7 +127,7 @@ _ltree_compress(PG_FUNCTION_ARGS)
127127
PG_RETURN_POINTER(retval);
128128
}
129129
len=LTG_HDRSIZE;
130-
key= (ltree_gist*)palloc(len);
130+
key= (ltree_gist*)palloc0(len);
131131
SET_VARSIZE(key,len);
132132
key->flag=LTG_ALLTRUE;
133133

@@ -207,7 +207,7 @@ _ltree_union(PG_FUNCTION_ARGS)
207207
}
208208

209209
len=LTG_HDRSIZE+ ((flag&LTG_ALLTRUE) ?0 :ASIGLEN);
210-
result= (ltree_gist*)palloc(len);
210+
result= (ltree_gist*)palloc0(len);
211211
SET_VARSIZE(result,len);
212212
result->flag=flag;
213213
if (!LTG_ISALLTRUE(result))
@@ -344,26 +344,26 @@ _ltree_picksplit(PG_FUNCTION_ARGS)
344344
/* form initial .. */
345345
if (LTG_ISALLTRUE(GETENTRY(entryvec,seed_1)))
346346
{
347-
datum_l= (ltree_gist*)palloc(LTG_HDRSIZE);
347+
datum_l= (ltree_gist*)palloc0(LTG_HDRSIZE);
348348
SET_VARSIZE(datum_l,LTG_HDRSIZE);
349349
datum_l->flag=LTG_ALLTRUE;
350350
}
351351
else
352352
{
353-
datum_l= (ltree_gist*)palloc(LTG_HDRSIZE+ASIGLEN);
353+
datum_l= (ltree_gist*)palloc0(LTG_HDRSIZE+ASIGLEN);
354354
SET_VARSIZE(datum_l,LTG_HDRSIZE+ASIGLEN);
355355
datum_l->flag=0;
356356
memcpy((void*)LTG_SIGN(datum_l), (void*)LTG_SIGN(GETENTRY(entryvec,seed_1)),sizeof(ABITVEC));
357357
}
358358
if (LTG_ISALLTRUE(GETENTRY(entryvec,seed_2)))
359359
{
360-
datum_r= (ltree_gist*)palloc(LTG_HDRSIZE);
360+
datum_r= (ltree_gist*)palloc0(LTG_HDRSIZE);
361361
SET_VARSIZE(datum_r,LTG_HDRSIZE);
362362
datum_r->flag=LTG_ALLTRUE;
363363
}
364364
else
365365
{
366-
datum_r= (ltree_gist*)palloc(LTG_HDRSIZE+ASIGLEN);
366+
datum_r= (ltree_gist*)palloc0(LTG_HDRSIZE+ASIGLEN);
367367
SET_VARSIZE(datum_r,LTG_HDRSIZE+ASIGLEN);
368368
datum_r->flag=0;
369369
memcpy((void*)LTG_SIGN(datum_r), (void*)LTG_SIGN(GETENTRY(entryvec,seed_2)),sizeof(ABITVEC));

‎contrib/ltree/_ltree_op.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ _ltree_extract_isparent(PG_FUNCTION_ARGS)
219219
PG_RETURN_NULL();
220220
}
221221

222-
item= (ltree*)palloc(VARSIZE(found));
222+
item= (ltree*)palloc0(VARSIZE(found));
223223
memcpy(item,found,VARSIZE(found));
224224

225225
PG_FREE_IF_COPY(la,0);
@@ -242,7 +242,7 @@ _ltree_extract_risparent(PG_FUNCTION_ARGS)
242242
PG_RETURN_NULL();
243243
}
244244

245-
item= (ltree*)palloc(VARSIZE(found));
245+
item= (ltree*)palloc0(VARSIZE(found));
246246
memcpy(item,found,VARSIZE(found));
247247

248248
PG_FREE_IF_COPY(la,0);
@@ -265,7 +265,7 @@ _ltq_extract_regex(PG_FUNCTION_ARGS)
265265
PG_RETURN_NULL();
266266
}
267267

268-
item= (ltree*)palloc(VARSIZE(found));
268+
item= (ltree*)palloc0(VARSIZE(found));
269269
memcpy(item,found,VARSIZE(found));
270270

271271
PG_FREE_IF_COPY(la,0);
@@ -288,7 +288,7 @@ _ltxtq_extract_exec(PG_FUNCTION_ARGS)
288288
PG_RETURN_NULL();
289289
}
290290

291-
item= (ltree*)palloc(VARSIZE(found));
291+
item= (ltree*)palloc0(VARSIZE(found));
292292
memcpy(item,found,VARSIZE(found));
293293

294294
PG_FREE_IF_COPY(la,0);

‎contrib/ltree/ltree_gist.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ ltree_compress(PG_FUNCTION_ARGS)
7272
ltree*val= (ltree*)DatumGetPointer(PG_DETOAST_DATUM(entry->key));
7373
int32len=LTG_HDRSIZE+VARSIZE(val);
7474

75-
key= (ltree_gist*)palloc(len);
75+
key= (ltree_gist*)palloc0(len);
7676
SET_VARSIZE(key,len);
7777
key->flag=LTG_ONENODE;
7878
memcpy((void*)LTG_NODE(key), (void*)val,VARSIZE(val));
@@ -229,7 +229,7 @@ ltree_union(PG_FUNCTION_ARGS)
229229
isleqr= (left==right||ISEQ(left,right)) ? true : false;
230230
*size=LTG_HDRSIZE+ ((isalltrue) ?0 :SIGLEN)+VARSIZE(left)+ ((isleqr) ?0 :VARSIZE(right));
231231

232-
result= (ltree_gist*)palloc(*size);
232+
result= (ltree_gist*)palloc0(*size);
233233
SET_VARSIZE(result,*size);
234234
result->flag=0;
235235

@@ -402,7 +402,7 @@ ltree_picksplit(PG_FUNCTION_ARGS)
402402
lu_l=LTG_GETLNODE(GETENTRY(entryvec,array[FirstOffsetNumber].index));
403403
isleqr= (lu_l==lu_r||ISEQ(lu_l,lu_r)) ? true : false;
404404
size=LTG_HDRSIZE+ ((lisat) ?0 :SIGLEN)+VARSIZE(lu_l)+ ((isleqr) ?0 :VARSIZE(lu_r));
405-
lu= (ltree_gist*)palloc(size);
405+
lu= (ltree_gist*)palloc0(size);
406406
SET_VARSIZE(lu,size);
407407
lu->flag=0;
408408
if (lisat)
@@ -419,7 +419,7 @@ ltree_picksplit(PG_FUNCTION_ARGS)
419419
ru_l=LTG_GETLNODE(GETENTRY(entryvec,array[1+ ((maxoff-FirstOffsetNumber+1) /2)].index));
420420
isleqr= (ru_l==ru_r||ISEQ(ru_l,ru_r)) ? true : false;
421421
size=LTG_HDRSIZE+ ((risat) ?0 :SIGLEN)+VARSIZE(ru_l)+ ((isleqr) ?0 :VARSIZE(ru_r));
422-
ru= (ltree_gist*)palloc(size);
422+
ru= (ltree_gist*)palloc0(size);
423423
SET_VARSIZE(ru,size);
424424
ru->flag=0;
425425
if (risat)
@@ -461,7 +461,7 @@ gist_isparent(ltree_gist *key, ltree *query)
461461
staticltree*
462462
copy_ltree(ltree*src)
463463
{
464-
ltree*dst= (ltree*)palloc(VARSIZE(src));
464+
ltree*dst= (ltree*)palloc0(VARSIZE(src));
465465

466466
memcpy(dst,src,VARSIZE(src));
467467
returndst;

‎contrib/ltree/ltree_op.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ inner_subltree(ltree *t, int32 startpos, int32 endpos)
230230
ptr=LEVEL_NEXT(ptr);
231231
}
232232

233-
res= (ltree*)palloc(LTREE_HDRSIZE+ (end-start));
233+
res= (ltree*)palloc0(LTREE_HDRSIZE+ (end-start));
234234
SET_VARSIZE(res,LTREE_HDRSIZE+ (end-start));
235235
res->numlevel=endpos-startpos;
236236

@@ -287,7 +287,7 @@ ltree_concat(ltree *a, ltree *b)
287287
{
288288
ltree*r;
289289

290-
r= (ltree*)palloc(VARSIZE(a)+VARSIZE(b)-LTREE_HDRSIZE);
290+
r= (ltree*)palloc0(VARSIZE(a)+VARSIZE(b)-LTREE_HDRSIZE);
291291
SET_VARSIZE(r,VARSIZE(a)+VARSIZE(b)-LTREE_HDRSIZE);
292292
r->numlevel=a->numlevel+b->numlevel;
293293

@@ -469,7 +469,7 @@ lca_inner(ltree **a, int len)
469469
l1=LEVEL_NEXT(l1);
470470
}
471471

472-
res= (ltree*)palloc(reslen);
472+
res= (ltree*)palloc0(reslen);
473473
SET_VARSIZE(res,reslen);
474474
res->numlevel=num;
475475

‎contrib/ltree/ltxtquery_io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ queryin(char *buf)
353353
errmsg("ltxtquery is too large")));
354354
commonlen=COMPUTESIZE(state.num,state.sumlen);
355355

356-
query= (ltxtquery*)palloc(commonlen);
356+
query= (ltxtquery*)palloc0(commonlen);
357357
SET_VARSIZE(query,commonlen);
358358
query->size=state.num;
359359
ptr=GETQUERY(query);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp