aboutsummaryrefslogtreecommitdiffstats
path: root/src/fringe.c
diff options
context:
space:
mode:
authorPaul Eggert2017-12-09 13:57:38 -0800
committerPaul Eggert2017-12-12 15:17:12 -0800
commit4295050e1194af13afa26403dd3ebdff80824ae0 (patch)
tree354002f3c84f4d8341bb07c5f68529f660a9a405 /src/fringe.c
parent881abfc7fb55db2d00adf352100cc58a6a86c176 (diff)
downloademacs-4295050e1194af13afa26403dd3ebdff80824ae0.tar.gz
emacs-4295050e1194af13afa26403dd3ebdff80824ae0.zip
Narrow pointer bounds when appropriate
This typically occurs in a storage manager, where the caller is expected to access only the newly-allocated object, instead of using the returned value to access unrelated parts of the heap. * src/alloc.c (allocate_string, allocate_string_data) (compact_small_strings, find_string_data_in_pure) (sweep_strings, setup_on_free_list, allocate_vectorlike (pure_alloc): * src/bytecode.c (exec_byte_code): * src/callint.c (Fcall_interactively): * src/dispnew.c (scrolling): * src/editfns.c (styled_format): * src/frame.c (xrdb_get_resource, x_get_resource_string): * src/fringe.c (Fdefine_fringe_bitmap): * src/gmalloc.c (malloc, realloc, aligned_alloc): Narrow pointer bounds when appropriate. * src/alloc.c (SDATA_OF_STRING): * src/lisp.h (make_lisp_symbol) [__CHKP__]: Widen bounds here, though. * src/bytecode.c, src/callint.c, src/dispnew.c, src/editfns.c: * src/emacs.c, src/frame.c, src/fringe.c: Include ptr-bounds.h. * src/ptr-bounds.h (ptr_bounds_clip): New function.
Diffstat (limited to 'src/fringe.c')
-rw-r--r--src/fringe.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/fringe.c b/src/fringe.c
index 087ef33434d..a5581173743 100644
--- a/src/fringe.c
+++ b/src/fringe.c
@@ -24,6 +24,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
24 24
25#include "lisp.h" 25#include "lisp.h"
26#include "frame.h" 26#include "frame.h"
27#include "ptr-bounds.h"
27#include "window.h" 28#include "window.h"
28#include "dispextern.h" 29#include "dispextern.h"
29#include "buffer.h" 30#include "buffer.h"
@@ -1591,7 +1592,9 @@ If BITMAP already exists, the existing definition is replaced. */)
1591 fb.dynamic = true; 1592 fb.dynamic = true;
1592 1593
1593 xfb = xmalloc (sizeof fb + fb.height * BYTES_PER_BITMAP_ROW); 1594 xfb = xmalloc (sizeof fb + fb.height * BYTES_PER_BITMAP_ROW);
1594 fb.bits = b = (unsigned short *) (xfb + 1); 1595 fb.bits = b = ((unsigned short *)
1596 ptr_bounds_clip (xfb + 1, fb.height * BYTES_PER_BITMAP_ROW));
1597 xfb = ptr_bounds_clip (xfb, sizeof *xfb);
1595 memset (b, 0, fb.height); 1598 memset (b, 0, fb.height);
1596 1599
1597 j = 0; 1600 j = 0;