From: Paul Eggert Date: Thu, 18 Aug 2011 08:37:41 +0000 (-0700) Subject: * doc.c (get_doc_string): Rework so that X-Git-Tag: emacs-pretest-24.0.90~104^2~152^2~77 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d31850da41f8dba08684acd2e8addd7127089404;p=emacs.git * 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. --- diff --git a/src/ChangeLog b/src/ChangeLog index 4613192187e..2677f03944f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -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. diff --git a/src/doc.c b/src/doc.c index eb8ff3c2521..83e943c42b8 100644 --- a/src/doc.c +++ b/src/doc.c @@ -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)); }