Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Mullvad Browser
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
The Tor Project
Applications
Mullvad Browser
Commits
13b36b3f
Commit
13b36b3f
authored
8 years ago
by
Lee Salzman
Browse files
Options
Downloads
Patches
Plain Diff
Bug 1339637 - fix overflow in SkClampRange::init(). r=jrmuizel
MozReview-Commit-ID: 7NtQP5QPsFk
parent
2e41bcb1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gfx/skia/skia/src/effects/gradients/SkClampRange.cpp
+18
-4
18 additions, 4 deletions
gfx/skia/skia/src/effects/gradients/SkClampRange.cpp
with
18 additions
and
4 deletions
gfx/skia/skia/src/effects/gradients/SkClampRange.cpp
+
18
−
4
View file @
13b36b3f
...
...
@@ -33,6 +33,21 @@ static bool sk_64_smul_check(int64_t a, int64_t b, int64_t* result) {
return
true
;
}
static
bool
sk_64_sadd_check
(
int64_t
a
,
int64_t
b
,
int64_t
*
result
)
{
if
(
a
>
0
)
{
if
(
b
>
std
::
numeric_limits
<
int64_t
>::
max
()
-
a
)
{
return
false
;
}
}
else
{
if
(
b
<
std
::
numeric_limits
<
int64_t
>::
min
()
-
a
)
{
return
false
;
}
}
*
result
=
a
+
b
;
return
true
;
}
/*
* returns [0..count] for the number of steps (<= count) for which x0 <= edge
* given each step is followed by x0 += dx
...
...
@@ -82,16 +97,15 @@ void SkClampRange::init(SkGradFixed fx0, SkGradFixed dx0, int count, int v0, int
int64_t
dx
=
dx0
;
// start with ex equal to the last computed value
int64_t
count_times_dx
;
if
(
!
sk_64_smul_check
(
count
-
1
,
dx
,
&
count_times_dx
))
{
int64_t
count_times_dx
,
ex
;
if
(
!
sk_64_smul_check
(
count
-
1
,
dx
,
&
count_times_dx
)
||
!
sk_64_sadd_check
(
fx
,
count_times_dx
,
&
ex
))
{
// we can't represent the computed end in 32.32, so just draw something (first color)
fCount1
=
fCount2
=
0
;
fCount0
=
count
;
return
;
}
int64_t
ex
=
fx
+
(
count
-
1
)
*
dx
;
if
((
uint64_t
)(
fx
|
ex
)
<=
kFracMax_SkGradFixed
)
{
fCount0
=
fCount2
=
0
;
fCount1
=
count
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment