From: Tom Prince <tom.prince@ualberta.net>
To: Andrew Young <youngar17@gmail.com>, emacs-orgmode@gnu.org
Cc: Tom Prince <tom.prince@ualberta.net>
Subject: [PATCH] Fix a number of potential infinite loops due to unsgined underflow.
Date: Fri, 8 Feb 2013 20:01:37 -0700 [thread overview]
Message-ID: <1360378897-22577-1-git-send-email-tom.prince@ualberta.net> (raw)
I discovered this, when trying to merge a file, with a tag that
overhangs the right margin. Trying to merge the following line
with itself (with --rmargin less than 10) the causes the driver
to output spaces forever:
** abc :TAG:
---
src/org_heading.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/org_heading.c b/src/org_heading.c
index 264512e..0c58046 100644
--- a/src/org_heading.c
+++ b/src/org_heading.c
@@ -316,7 +316,7 @@ org_heading_set_entire_text (org_heading *heading, char *string, int length,
* This is the whitespace between the stars and heading.
* Store it as a substring.
*/
- for (count = 0; count < ubound - lbound; count++)
+ for (count = 0; (lbound + count) < ubound; count++)
{
if (!iswhitespace (string[lbound + count]))
{
@@ -357,7 +357,7 @@ org_heading_set_entire_text (org_heading *heading, char *string, int length,
/* Scan trailing linebreaks
* Scan right to left.
*/
- for (count = 0; count < (ubound - lbound); count++)
+ for (count = 0; (lbound + count) < ubound; count++)
{
if (!islinebreak (string[ubound - count - 1]))
{
@@ -385,7 +385,7 @@ org_heading_set_entire_text (org_heading *heading, char *string, int length,
bool foundtags = false;
bool done = false;
- for (i = 0; i < (ubound - lbound); i++)
+ for (i = 0; (lbound + i) < ubound; i++)
{
if (string [ubound - i - 1] == ':')
{
@@ -397,7 +397,7 @@ org_heading_set_entire_text (org_heading *heading, char *string, int length,
debug_msg (DOC_ELT, 5, "Setting tags_ubound =%d\n", tags_ubound);
}
int j;
- for (j = 2; j < (tags_ubound - lbound); j++)
+ for (j = 2; (lbound + j) < tags_ubound; j++)
{
if (iswhitespace (string[tags_ubound - j]))
{
@@ -1902,7 +1902,7 @@ merge_tags (substr anc_str, substr loc_str, substr rem_str, size_t curr_col,
int i;
doc_stream_putc(' ', out);
//curr_col += 1;
- for (i=0; i < (ctxt->rmargin - 1 - char_count - curr_col); i++)
+ for (i=0; 1 + char_count + curr_col + i < ctxt->rmargin; i++)
{
doc_stream_putc(' ', out);
}
--
1.8.0.2
next reply other threads:[~2013-02-09 3:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-09 3:01 Tom Prince [this message]
2013-02-11 14:38 ` [PATCH] Fix a number of potential infinite loops due to unsgined underflow Bastien
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1360378897-22577-1-git-send-email-tom.prince@ualberta.net \
--to=tom.prince@ualberta.net \
--cc=emacs-orgmode@gnu.org \
--cc=youngar17@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.