The type number of a sign is negative when the sign name does not
start with a digit. This is not correctly implemented.
The attached patch fixes this, as well as a memory not freed on error.
Xavier
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -6673,11 +6673,6 @@
sp = (sign_T *)alloc_clear((unsigned)sizeof(sign_T));
if (sp == NULL)
return;
- if (sp_prev == NULL)
- first_sign = sp;
- else
- sp_prev->sn_next = sp;
- sp->sn_name = vim_strnsave(arg, (int)(p - arg));
/* If the name is a number use that for the typenr,
* otherwise use a negative number. */
@@ -6690,13 +6685,14 @@
for (lp = first_sign; lp != NULL; lp = lp->sn_next)
{
- if (lp->sn_typenr == last_sign_typenr)
+ if (lp->sn_typenr == -last_sign_typenr)
{
--last_sign_typenr;
if (last_sign_typenr == 0)
last_sign_typenr = MAX_TYPENR;
if (last_sign_typenr == start)
{
+ vim_free(sp);
EMSG(_("E612: Too many signs defined"));
return;
}
@@ -6705,10 +6701,16 @@
}
}
- sp->sn_typenr = last_sign_typenr--;
+ sp->sn_typenr = -last_sign_typenr;
+ --last_sign_typenr;
if (last_sign_typenr == 0)
last_sign_typenr = MAX_TYPENR; /* wrap around */
}
+ if (sp_prev == NULL)
+ first_sign = sp;
+ else
+ sp_prev->sn_next = sp;
+ sp->sn_name = vim_strnsave(arg, (int)(p - arg));
}
/* set values for a defined sign. */