Skip to content

Commit cfd99cb

Browse files
committed
Fixed a bug in FlagDescriptor::ToBitString() where flags with value 0 was always matching any value.
1 parent 3db95a7 commit cfd99cb

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

src/shellextension/utils.cpp

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,25 @@ template <class T> class FlagDescriptor
107107
const T& flag = flags[index].value;
108108
const char* name = flags[index].name;
109109

110-
//if flag is set
111-
if ((value & flag) == flag)
110+
// Test special case where a flag has no bit set (flag == 0x00)
111+
// The only time where it should be reported is when the value is also 0.
112+
if (flag == 0)
112113
{
113-
if (!desc.empty())
114-
desc.append("|");
115-
desc.append(name);
114+
if (flag == value)
115+
{
116+
desc = name;
117+
break;
118+
}
119+
}
120+
else
121+
{
122+
//if flag is set
123+
if ((value & flag) == flag)
124+
{
125+
if (!desc.empty())
126+
desc.append("|");
127+
desc.append(name);
128+
}
116129
}
117130

118131
//next flag

0 commit comments

Comments
 (0)