diff options
| author | Gareth Rees | 2013-05-22 16:45:45 +0100 |
|---|---|---|
| committer | Gareth Rees | 2013-05-22 16:45:45 +0100 |
| commit | 439a5958b23b3da62db53bd235b0dd25f67e81b4 (patch) | |
| tree | 0bae66f648c2ecbad4ce4d8757d2160f86a3f062 /mps/code | |
| parent | 9575a90de2931bd33b831c2bc674c30736f1fe72 (diff) | |
| download | emacs-439a5958b23b3da62db53bd235b0dd25f67e81b4.tar.gz emacs-439a5958b23b3da62db53bd235b0dd25f67e81b4.zip | |
Avoid undefined behaviour in ring_elt by using parent (and thus offsetof) instead of deferencing a null pointer. add missing typedef for rememberedsummaryblockstruct. update ring design accordingly.
Copied from Perforce
Change: 182084
ServerID: perforce.ravenbrook.com
Diffstat (limited to 'mps/code')
| -rw-r--r-- | mps/code/ring.h | 6 | ||||
| -rw-r--r-- | mps/code/traceanc.c | 8 |
2 files changed, 7 insertions, 7 deletions
diff --git a/mps/code/ring.h b/mps/code/ring.h index c7d14ee43d8..d5b64076f6c 100644 --- a/mps/code/ring.h +++ b/mps/code/ring.h | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | /* ring.h: RING INTERFACE | 1 | /* ring.h: RING INTERFACE |
| 2 | * | 2 | * |
| 3 | * $Id$ | 3 | * $Id$ |
| 4 | * Copyright (c) 2001,2003 Ravenbrook Limited. See end of file for license. | 4 | * Copyright (c) 2001-2013 Ravenbrook Limited. See end of file for license. |
| 5 | * Portions copyright (C) 2001 Global Graphics Software. | 5 | * Portions copyright (C) 2001 Global Graphics Software. |
| 6 | */ | 6 | */ |
| 7 | 7 | ||
| @@ -101,7 +101,7 @@ extern Ring (RingPrev)(Ring ring); | |||
| 101 | 101 | ||
| 102 | /* .ring.elt: See <design/ring/#elt> */ | 102 | /* .ring.elt: See <design/ring/#elt> */ |
| 103 | #define RING_ELT(type, field, node) \ | 103 | #define RING_ELT(type, field, node) \ |
| 104 | ((type)(void *)((char *)(node) - (size_t)(&((type)0)->field))) | 104 | PARENT(type ## Struct, field, node) |
| 105 | 105 | ||
| 106 | /* .ring.for: See <design/ring/#for> */ | 106 | /* .ring.for: See <design/ring/#for> */ |
| 107 | #define RING_FOR(node, ring, next) \ | 107 | #define RING_FOR(node, ring, next) \ |
| @@ -115,7 +115,7 @@ extern Ring (RingPrev)(Ring ring); | |||
| 115 | 115 | ||
| 116 | /* C. COPYRIGHT AND LICENSE | 116 | /* C. COPYRIGHT AND LICENSE |
| 117 | * | 117 | * |
| 118 | * Copyright (C) 2001-2003 Ravenbrook Limited <http://www.ravenbrook.com/>. | 118 | * Copyright (C) 2001-2013 Ravenbrook Limited <http://www.ravenbrook.com/>. |
| 119 | * All rights reserved. This is an open source license. Contact | 119 | * All rights reserved. This is an open source license. Contact |
| 120 | * Ravenbrook for commercial licensing options. | 120 | * Ravenbrook for commercial licensing options. |
| 121 | * | 121 | * |
diff --git a/mps/code/traceanc.c b/mps/code/traceanc.c index e4248580a19..1efb876e2cc 100644 --- a/mps/code/traceanc.c +++ b/mps/code/traceanc.c | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | /* traceanc.c: ANCILLARY SUPPORT FOR TRACER | 1 | /* traceanc.c: ANCILLARY SUPPORT FOR TRACER |
| 2 | * | 2 | * |
| 3 | * $Id$ | 3 | * $Id$ |
| 4 | * Copyright (c) 2001-2003, 2006-2008 Ravenbrook Limited. | 4 | * Copyright (c) 2001-2013 Ravenbrook Limited. |
| 5 | * See end of file for license. | 5 | * See end of file for license. |
| 6 | * Portions copyright (C) 2002 Global Graphics Software. | 6 | * Portions copyright (C) 2002 Global Graphics Software. |
| 7 | * | 7 | * |
| @@ -637,13 +637,13 @@ Res ArenaCollect(Globals globals, int why) | |||
| 637 | 637 | ||
| 638 | /* Low level stuff for Expose / Remember / Restore */ | 638 | /* Low level stuff for Expose / Remember / Restore */ |
| 639 | 639 | ||
| 640 | struct RememberedSummaryBlockStruct { | 640 | typedef struct RememberedSummaryBlockStruct { |
| 641 | RingStruct globalRing; /* link on globals->rememberedSummaryRing */ | 641 | RingStruct globalRing; /* link on globals->rememberedSummaryRing */ |
| 642 | struct SummaryPair { | 642 | struct SummaryPair { |
| 643 | Addr base; | 643 | Addr base; |
| 644 | RefSet summary; | 644 | RefSet summary; |
| 645 | } the[RememberedSummaryBLOCK]; | 645 | } the[RememberedSummaryBLOCK]; |
| 646 | }; | 646 | } RememberedSummaryBlockStruct; |
| 647 | 647 | ||
| 648 | typedef struct RememberedSummaryBlockStruct *RememberedSummaryBlock; | 648 | typedef struct RememberedSummaryBlockStruct *RememberedSummaryBlock; |
| 649 | 649 | ||
| @@ -793,7 +793,7 @@ static void arenaForgetProtection(Globals globals) | |||
| 793 | 793 | ||
| 794 | /* C. COPYRIGHT AND LICENSE | 794 | /* C. COPYRIGHT AND LICENSE |
| 795 | * | 795 | * |
| 796 | * Copyright (C) 2001-2003, 2006-2008 Ravenbrook Limited | 796 | * Copyright (C) 2001-2013 Ravenbrook Limited |
| 797 | * <http://www.ravenbrook.com/>. | 797 | * <http://www.ravenbrook.com/>. |
| 798 | * All rights reserved. This is an open source license. Contact | 798 | * All rights reserved. This is an open source license. Contact |
| 799 | * Ravenbrook for commercial licensing options. | 799 | * Ravenbrook for commercial licensing options. |