summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--Src/prompt.c16
2 files changed, 20 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index fea458cff..323ade3a9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-07-10 Peter Stephenson <p.w.stephenson@ntlworld.com>
+
+ * 27125: Src/prompt.c: handle nested use of colour code buffer
+ allocation.
+
2009-07-10 Peter Stephenson <pws@csr.com>
* 27122: Doc/Zsh/options.yo, Src/jobs.c, Src/options.c, Src/zsh.h:
@@ -11945,5 +11950,5 @@
*****************************************************
* This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.4733 $
+* $Revision: 1.4734 $
*****************************************************
diff --git a/Src/prompt.c b/Src/prompt.c
index e56b70d0b..afb9777a0 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -1764,13 +1764,18 @@ struct colour_sequences {
struct colour_sequences fg_bg_sequences[2];
/*
- * We need a buffer for colour sequence compostion. It may
+ * We need a buffer for colour sequence composition. It may
* vary depending on the sequences set. However, it's inefficient
* allocating it separately every time we send a colour sequence,
* so do it once per refresh.
*/
static char *colseq_buf;
+/*
+ * Count how often this has been allocated, for recursive usage.
+ */
+static int colseq_buf_allocs;
+
/**/
void
set_default_colour_sequences(void)
@@ -1801,9 +1806,13 @@ set_colour_code(char *str, char **var)
mod_export void
allocate_colour_buffer(void)
{
- char **atrs = getaparam("zle_highlight");
+ char **atrs;
int lenfg, lenbg, len;
+ if (colseq_buf_allocs++)
+ return;
+
+ atrs = getaparam("zle_highlight");
if (atrs) {
for (; *atrs; atrs++) {
if (strpfx("fg_start_code:", *atrs)) {
@@ -1846,6 +1855,9 @@ allocate_colour_buffer(void)
mod_export void
free_colour_buffer(void)
{
+ if (--colseq_buf_allocs)
+ return;
+
DPUTS(!colseq_buf, "Freeing colour sequence buffer without alloc");
/* Free buffer for colour code composition */
free(colseq_buf);