1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-27 07:37:33 +00:00

* doc.c (get_doc_string): Rework so that

get_doc_string_buffer_size is the actual buffer size, rather than
being 1 less than the actual buffer size; this makes xpalloc more
convenient.
This commit is contained in:
Paul Eggert 2011-08-18 01:37:41 -07:00
parent bc81e2c4e8
commit d31850da41
2 changed files with 8 additions and 3 deletions

View File

@ -2,6 +2,11 @@
Integer and memory overflow issues (Bug#9196).
* doc.c (get_doc_string): Rework so that
get_doc_string_buffer_size is the actual buffer size, rather than
being 1 less than the actual buffer size; this makes xpalloc more
convenient.
* image.c (x_allocate_bitmap_record, cache_image):
* xselect.c (Fx_register_dnd_atom):
Simplify previous changes by using xpalloc.

View File

@ -166,19 +166,19 @@ get_doc_string (Lisp_Object filepos, int unibyte, int definition)
p = get_doc_string_buffer;
while (1)
{
ptrdiff_t space_left = (get_doc_string_buffer_size
ptrdiff_t space_left = (get_doc_string_buffer_size - 1
- (p - get_doc_string_buffer));
int nread;
/* Allocate or grow the buffer if we need to. */
if (space_left == 0)
if (space_left <= 0)
{
ptrdiff_t in_buffer = p - get_doc_string_buffer;
get_doc_string_buffer =
xpalloc (get_doc_string_buffer, &get_doc_string_buffer_size,
16 * 1024, -1, 1);
p = get_doc_string_buffer + in_buffer;
space_left = (get_doc_string_buffer_size
space_left = (get_doc_string_buffer_size - 1
- (p - get_doc_string_buffer));
}