mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
TW-1723: task info causes segfault
- Thanks to Roman Golovin. - Calls like 'context.columns[name]' autovivify the key 'name' with a default ctor value, which ends up polluting the context.columns map with every unique attribute name, which is a lot of 'annotation_nnnnnnnnnn' attributes.
This commit is contained in:
parent
fdda485032
commit
79189c448c
4 changed files with 37 additions and 31 deletions
|
@ -362,28 +362,31 @@ int CmdInfo::execute (std::string& output)
|
|||
std::string type;
|
||||
for (auto& att: all)
|
||||
{
|
||||
Column* col = context.columns[att];
|
||||
if (col && col->is_uda ())
|
||||
if (context.columns.find (att) != context.columns.end ())
|
||||
{
|
||||
std::string value = task.get (att);
|
||||
if (value != "")
|
||||
Column* col = context.columns[att];
|
||||
if (col->is_uda ())
|
||||
{
|
||||
row = view.addRow ();
|
||||
view.set (row, 0, col->label ());
|
||||
|
||||
if (type == "date")
|
||||
value = ISO8601d (value).toString (dateformat);
|
||||
else if (type == "duration")
|
||||
std::string value = task.get (att);
|
||||
if (value != "")
|
||||
{
|
||||
ISO8601p iso;
|
||||
std::string::size_type cursor = 0;
|
||||
if (iso.parse (value, cursor))
|
||||
value = (std::string) Variant ((time_t) iso, Variant::type_duration);
|
||||
else
|
||||
value = "PT0S";
|
||||
}
|
||||
row = view.addRow ();
|
||||
view.set (row, 0, col->label ());
|
||||
|
||||
view.set (row, 1, value);
|
||||
if (type == "date")
|
||||
value = ISO8601d (value).toString (dateformat);
|
||||
else if (type == "duration")
|
||||
{
|
||||
ISO8601p iso;
|
||||
std::string::size_type cursor = 0;
|
||||
if (iso.parse (value, cursor))
|
||||
value = (std::string) Variant ((time_t) iso, Variant::type_duration);
|
||||
else
|
||||
value = "PT0S";
|
||||
}
|
||||
|
||||
view.set (row, 1, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -393,7 +396,7 @@ int CmdInfo::execute (std::string& output)
|
|||
for (auto& att : all)
|
||||
{
|
||||
if (att.substr (0, 11) != "annotation_" &&
|
||||
! context.columns[att])
|
||||
context.columns.find (att) == context.columns.end ())
|
||||
{
|
||||
row = view.addRow ();
|
||||
view.set (row, 0, "[" + att);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue