event_data::blank redefined to prevent confusion with NULL values causing premature varadic argument termination leading to incomplete event data

This commit is contained in:
Simon Rozman 2016-10-25 13:01:47 +02:00
parent 0fcfe95e84
commit ce1bc5951e

View File

@ -126,7 +126,7 @@ namespace winstd
{ {
Ptr = 0; Ptr = 0;
Size = 0; Size = 0;
Reserved = 0; Reserved = (ULONG)-1; // Used for varadic argument terminator.
} }
@ -215,7 +215,7 @@ namespace winstd
/// ///
/// \note This class is saves a reference to the data only. Therefore, data must be kept available. /// \note This class is saves a reference to the data only. Therefore, data must be kept available.
/// ///
inline event_data(_In_bytecount_(size) const void *data, ULONG size) inline event_data(_In_bytecount_(size) const void *data, _In_ ULONG size)
{ {
EventDataDescCreate(this, data, size); EventDataDescCreate(this, data, size);
} }
@ -478,7 +478,9 @@ namespace winstd
// Preallocate array. // Preallocate array.
for (param_count = 0;; param_count++) { for (param_count = 0;; param_count++) {
const EVENT_DATA_DESCRIPTOR &p = va_arg(arg, const EVENT_DATA_DESCRIPTOR); const EVENT_DATA_DESCRIPTOR &p = va_arg(arg, const EVENT_DATA_DESCRIPTOR);
if (!p.Ptr) break; if (p.Ptr == winstd::event_data::blank.Ptr &&
p.Size == winstd::event_data::blank.Size &&
p.Reserved == winstd::event_data::blank.Reserved) break;
} }
params.reserve(param_count); params.reserve(param_count);
@ -486,7 +488,9 @@ namespace winstd
arg = arg_start; arg = arg_start;
for (;;) { for (;;) {
const EVENT_DATA_DESCRIPTOR &p = va_arg(arg, const EVENT_DATA_DESCRIPTOR); const EVENT_DATA_DESCRIPTOR &p = va_arg(arg, const EVENT_DATA_DESCRIPTOR);
if (!p.Ptr) break; if (p.Ptr == winstd::event_data::blank.Ptr &&
p.Size == winstd::event_data::blank.Size &&
p.Reserved == winstd::event_data::blank.Reserved) break;
params.push_back(p); params.push_back(p);
} }