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

Commita55a75f

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 parent84e5ce7 commita55a75f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

‎src/include/c.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
15-
* $Id: c.h,v 1.114 2002/01/22 19:02:39 tgl Exp $
15+
* $Id: c.h,v 1.114.2.1 2005/07/18 15:55:01 tgl Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -560,21 +560,22 @@ typedef NameData *Name;
560560
#defineMemSet(start,val,len) \
561561
do \
562562
{ \
563-
int32 * _start= (int32 *) (start); \
563+
void *_vstart= (void *) (start); \
564564
int_val = (val); \
565565
Size_len = (len); \
566566
\
567-
if ((((long)_start) & INT_ALIGN_MASK) == 0 && \
567+
if ((((long)_vstart) & INT_ALIGN_MASK) == 0 && \
568568
(_len & INT_ALIGN_MASK) == 0 && \
569569
_val == 0 && \
570570
_len <= MEMSET_LOOP_LIMIT) \
571571
{ \
572-
int32 * _stop = (int32 *) ((char *) _start + _len); \
572+
int32 *_start = (int32 *) _vstart; \
573+
int32 *_stop = (int32 *) ((char *) _start + _len); \
573574
while (_start < _stop) \
574575
*_start++ = 0; \
575576
} \
576577
else \
577-
memset((char *) _start, _val, _len); \
578+
memset(_vstart, _val, _len); \
578579
} while (0)
579580

580581
#defineMEMSET_LOOP_LIMIT 64

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp