emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Fix a number of potential infinite loops due to unsgined underflow.
@ 2013-02-09  3:01 Tom Prince
  2013-02-11 14:38 ` Bastien
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Prince @ 2013-02-09  3:01 UTC (permalink / raw)
  To: Andrew Young, emacs-orgmode; +Cc: Tom Prince

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix a number of potential infinite loops due to unsgined underflow.
  2013-02-09  3:01 [PATCH] Fix a number of potential infinite loops due to unsgined underflow Tom Prince
@ 2013-02-11 14:38 ` Bastien
  0 siblings, 0 replies; 2+ messages in thread
From: Bastien @ 2013-02-11 14:38 UTC (permalink / raw)
  To: Tom Prince; +Cc: Andrew Young, emacs-orgmode

Hi Tom,

Tom Prince <tom.prince@ualberta.net> writes:

> 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:

Good to know people are using Andrew's work!

Andrew, are you still maintainer this git merge driver?

Thanks,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-02-11 14:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-09  3:01 [PATCH] Fix a number of potential infinite loops due to unsgined underflow Tom Prince
2013-02-11 14:38 ` Bastien

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).