diff options
| author | Paul Eggert | 2011-08-18 01:37:41 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-08-18 01:37:41 -0700 |
| commit | d31850da41f8dba08684acd2e8addd7127089404 (patch) | |
| tree | 96c6d9e3d54243556def5ca7f45289384cf9f372 /src | |
| parent | bc81e2c4e885787603da3e0314d6ea45a43f7862 (diff) | |
| download | emacs-d31850da41f8dba08684acd2e8addd7127089404.tar.gz emacs-d31850da41f8dba08684acd2e8addd7127089404.zip | |
* 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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/doc.c | 6 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 4613192187e..2677f03944f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -2,6 +2,11 @@ | |||
| 2 | 2 | ||
| 3 | Integer and memory overflow issues (Bug#9196). | 3 | Integer and memory overflow issues (Bug#9196). |
| 4 | 4 | ||
| 5 | * doc.c (get_doc_string): Rework so that | ||
| 6 | get_doc_string_buffer_size is the actual buffer size, rather than | ||
| 7 | being 1 less than the actual buffer size; this makes xpalloc more | ||
| 8 | convenient. | ||
| 9 | |||
| 5 | * image.c (x_allocate_bitmap_record, cache_image): | 10 | * image.c (x_allocate_bitmap_record, cache_image): |
| 6 | * xselect.c (Fx_register_dnd_atom): | 11 | * xselect.c (Fx_register_dnd_atom): |
| 7 | Simplify previous changes by using xpalloc. | 12 | Simplify previous changes by using xpalloc. |
| @@ -166,19 +166,19 @@ get_doc_string (Lisp_Object filepos, int unibyte, int definition) | |||
| 166 | p = get_doc_string_buffer; | 166 | p = get_doc_string_buffer; |
| 167 | while (1) | 167 | while (1) |
| 168 | { | 168 | { |
| 169 | ptrdiff_t space_left = (get_doc_string_buffer_size | 169 | ptrdiff_t space_left = (get_doc_string_buffer_size - 1 |
| 170 | - (p - get_doc_string_buffer)); | 170 | - (p - get_doc_string_buffer)); |
| 171 | int nread; | 171 | int nread; |
| 172 | 172 | ||
| 173 | /* Allocate or grow the buffer if we need to. */ | 173 | /* Allocate or grow the buffer if we need to. */ |
| 174 | if (space_left == 0) | 174 | if (space_left <= 0) |
| 175 | { | 175 | { |
| 176 | ptrdiff_t in_buffer = p - get_doc_string_buffer; | 176 | ptrdiff_t in_buffer = p - get_doc_string_buffer; |
| 177 | get_doc_string_buffer = | 177 | get_doc_string_buffer = |
| 178 | xpalloc (get_doc_string_buffer, &get_doc_string_buffer_size, | 178 | xpalloc (get_doc_string_buffer, &get_doc_string_buffer_size, |
| 179 | 16 * 1024, -1, 1); | 179 | 16 * 1024, -1, 1); |
| 180 | p = get_doc_string_buffer + in_buffer; | 180 | p = get_doc_string_buffer + in_buffer; |
| 181 | space_left = (get_doc_string_buffer_size | 181 | space_left = (get_doc_string_buffer_size - 1 |
| 182 | - (p - get_doc_string_buffer)); | 182 | - (p - get_doc_string_buffer)); |
| 183 | } | 183 | } |
| 184 | 184 | ||