You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Prefetch Plugin Overflows when adding greater than 32-bit numbers #8569
I was configuring the prefetch plugin to use for HLS caching hit improvements, and captured the required patterns with regex and added the next segments to download according to matches on our HLS manifest files. However, one of these patters, uses numbering higher than the max signed 32-bit integer, thus I saw it was overflowing and wrapping back into the negative integers. Looking at the code, I see the overflow occurs on the function "evaluate" of the plugins/prefetch/plugin.cc file. Specifically on the following segment of code:
if (String::npos == pos) {
result = getValue(stmt);
} else {
unsigned a = getValue(stmt.substr(0, pos));
unsigned b = getValue(stmt.substr(pos + 1));
if ('+' == stmt[pos]) {
result = a + b;
} else {
result = a - b;
}
}
std::ostringstream convert;
convert << std::setw(len) << std::setfill('0') << result;
PrefetchDebug("evaluation of '%s' resulted in '%s'", v.c_str(), convert.str().c_str());
return convert.str();
For example, I am trying to add 2207264608520000 + 60060000. I tried striping the four 0s at the end from the pattern, but the resulting number is still greater than the max signed 32-bit integer.
I will try recompiling using long instead of int for the result, a and b variables, but I am not sure if the getValue function may impact as well.
Activity
mikeV02 commentedon Dec 29, 2021
Hello,
To confirm, changing result to long, and a and b to unsigned long did the trick.
Regards!
MiKe
bryancall commentedon Jan 4, 2022
@mikeV02 would you like to make a PR to fix this issue?