зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1711828 - Cap printed Watts to 6 characters. r=xpcom-reviewers,mccr8
If for some reason the input number is a very large double, printing it can overflow the 16-bytes buffers the function is called with. But anything above 1000W is very likely invalid. Differential Revision: https://phabricator.services.mozilla.com/D115446
This commit is contained in:
Родитель
3a691cdda6
Коммит
0f6971cac4
|
@ -614,9 +614,10 @@ static double JoulesToWatts(double aJoules) {
|
|||
|
||||
// "Normalize" here means convert kUnsupported_j to zero so it can be used in
|
||||
// additive expressions. All printed values are 5 or maybe 6 chars (though 6
|
||||
// chars would require a value > 100 W, which is unlikely).
|
||||
// chars would require a value > 100 W, which is unlikely). Values above 1000 W
|
||||
// are normalized to " n/a ", so 6 chars is the longest that may be printed.
|
||||
static void NormalizeAndPrintAsWatts(char* aBuf, double& aValue_J) {
|
||||
if (aValue_J == kUnsupported_j) {
|
||||
if (aValue_J == kUnsupported_j || aValue_J >= 1000) {
|
||||
aValue_J = 0;
|
||||
sprintf(aBuf, "%s", " n/a ");
|
||||
} else {
|
||||
|
|
Загрузка…
Ссылка в новой задаче