From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: Segfault in hrealloc somewhere between rpromts and syntax highlighting
Date: Sat, 12 Apr 2014 18:35:41 -0700 [thread overview]
Message-ID: <140412183541.ZM21282@torch.brasslantern.com> (raw)
In-Reply-To: <15AFC0D6-F14F-4ABE-AE4B-038654C25E35@kba.biglobe.ne.jp>
On Apr 13, 2:29am, Jun T. wrote:
} Subject: Re: Segfault in hrealloc somewhere between rpromts and syntax hig
}
} 2014/04/06 16:05, Bart Schaefer <schaefer@brasslantern.com> wrote:
} > diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c
} > index 3c7cff9..b916bd6 100644
} > (snip)
} > if (strcmp(zlemetaline, ol)) {
} > + zle_restore_positions();
}
} It seems this causes the following problem:
}
} $ echo foobar<RET>
} $ echo !$<TAB>
} $ echo fo
}
} Maybe zlemetacs/zlematall need not to be restored?
Hmm, I think it's more complicated than that. Assuming that the various
positions have been correctly updated when expansion changed the buffer,
then we don't want to restore *anything*, we just want to discard the
most recent saved state.
I'm not sure how that affects the state of any previous call to
zle_save_positions(), but I have to assume that if it's possible for
the stack to be more than one element deep here, then whoever else is
calling zle_store_positions() is planning to do a complete unwind of
whatever doexpandhist() may have done.
On the other hand, compresult.c simply makes sure that restoring the
positions doesn't affect zlemetall, so perhaps this is too much.
diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c
index b916bd6..499c4ae 100644
--- a/Src/Zle/zle_tricky.c
+++ b/Src/Zle/zle_tricky.c
@@ -2795,7 +2795,7 @@ doexpandhist(void)
if (!err) {
zlemetacs = excs;
if (strcmp(zlemetaline, ol)) {
- zle_restore_positions();
+ zle_free_positions();
unmetafy_line();
/* For vi mode -- reset the beginning-of-insertion pointer *
* to the beginning of the line. This seems a little silly, *
diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c
index 9cfa881..1089e27 100644
--- a/Src/Zle/zle_utils.c
+++ b/Src/Zle/zle_utils.c
@@ -710,6 +710,27 @@ zle_restore_positions(void)
}
/*
+ * Discard positions previously saved, the line has been updated.
+ */
+
+/**/
+mod_export void
+zle_free_positions(void)
+{
+ struct zle_position *oldpos = zle_positions;
+ struct zle_region *oldrhp;
+
+ zle_positions = oldpos->next;
+ oldrhp = oldpos->regions;
+ while (oldrhp) {
+ struct zle_region *nextrhp = oldrhp->next;
+ zfree(oldrhp, sizeof(*oldrhp));
+ oldrhp = nextrhp;
+ }
+ zfree(oldpos, sizeof(*oldpos));
+}
+
+/*
* Basic utility functions for adding to line or removing from line.
* At this level the counts supplied are raw character counts, so
* the calling code must be aware of combining characters where
prev parent reply other threads:[~2014-04-13 1:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-30 13:13 Sebastian Götte
2014-04-06 7:05 ` Bart Schaefer
2014-04-06 16:02 ` Peter Stephenson
2014-04-06 16:50 ` Bart Schaefer
2014-04-06 17:06 ` Peter Stephenson
2014-04-12 17:29 ` Jun T.
2014-04-13 1:35 ` Bart Schaefer [this message]
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=140412183541.ZM21282@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-workers@zsh.org \
/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 public inbox
https://git.vuxu.org/mirror/zsh/
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 NNTP newsgroup(s).