Fix tag_new() tag name

possible overflow + random memory access
This commit is contained in:
Philippe Pepiot 2010-12-03 11:06:33 +01:00
parent c90a5743b3
commit 77e458048d

View File

@ -508,18 +508,20 @@ tag_new(int s, char *name)
++conf.ntag[s];
/* TODO: memleak here */
if(!name || strlen(name) == 0)
{
if(conf.tagnamecount)
{
displayedName = zmalloc(2);
sprintf(displayedName, "[%d]", conf.ntag[s]);
/* displayedName = zmalloc(2); */
xasprintf(&displayedName, "[%d]", conf.ntag[s]);
}
else
displayedName = conf.default_tag.name;
}
else
displayedName = name;
displayedName = xstrdup(name);
Tag t = { displayedName, NULL, 0, 0,
conf.default_tag.mwfact, conf.default_tag.nmaster,