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

Commitac43da8

Browse files
committed
MemSet() must not cast its pointer argument to int32* until after it has
checked that the pointer is actually word-aligned. Casting a non-alignedpointer to int32* is technically illegal per the C spec, and some recentversions of gcc actually generate bad code for the memset() when givensuch a pointer. Per report from Andrew Morrow.
1 parentd0f312e commitac43da8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

‎src/include/c.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
15-
* $PostgreSQL: pgsql/src/include/c.h,v 1.187 2005/07/02 17:01:52 momjian Exp $
15+
* $PostgreSQL: pgsql/src/include/c.h,v 1.188 2005/07/18 15:53:28 tgl Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -630,21 +630,22 @@ typedef NameData *Name;
630630
#defineMemSet(start,val,len) \
631631
do \
632632
{ \
633-
int32 *_start = (int32 *) (start); \
633+
void *_vstart = (void *) (start); \
634634
int_val = (val); \
635635
Size_len = (len); \
636636
\
637-
if ((((long)_start) & INT_ALIGN_MASK) == 0 && \
637+
if ((((long)_vstart) & INT_ALIGN_MASK) == 0 && \
638638
(_len & INT_ALIGN_MASK) == 0 && \
639639
_val == 0 && \
640640
_len <= MEMSET_LOOP_LIMIT) \
641641
{ \
642+
int32 *_start = (int32 *) _vstart; \
642643
int32 *_stop = (int32 *) ((char *) _start + _len); \
643644
while (_start < _stop) \
644645
*_start++ = 0; \
645646
} \
646647
else \
647-
memset(_start, _val, _len); \
648+
memset(_vstart, _val, _len); \
648649
} while (0)
649650

650651
#defineMEMSET_LOOP_LIMIT 1024

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp