Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
htop
Commits
a94b0466
Commit
a94b0466
authored
9 years ago
by
Explorer09
Browse files
Options
Download
Email Patches
Plain Diff
Fix a potential array overflow.
parent
d56bcd8e
linear-graph-scan
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Meter.c
+5
-6
Meter.c
Meter.h
+1
-0
Meter.h
with
6 additions
and
6 deletions
+6
-6
Meter.c
View file @
a94b0466
...
...
@@ -70,6 +70,7 @@ typedef struct MeterClass_ {
#define Meter_defaultMode(this_) As_Meter(this_)->defaultMode
#define Meter_getItems(this_) As_Meter(this_)->curItems
#define Meter_setItems(this_, n_) As_Meter(this_)->curItems = (n_)
#define Meter_getMaxItems(this_) As_Meter(this_)->maxItems
#define Meter_attributes(this_) As_Meter(this_)->attributes
#define Meter_name(this_) As_Meter(this_)->name
#define Meter_uiName(this_) As_Meter(this_)->uiName
...
...
@@ -372,6 +373,10 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
if
(
!
this
->
drawData
)
{
this
->
drawData
=
calloc
(
1
,
sizeof
(
GraphData
));
GraphData
*
data
=
(
GraphData
*
)
this
->
drawData
;
if
(
!
data
->
prevItemSums
)
data
->
prevItemSums
=
calloc
(
Meter_getMaxItems
(
this
),
sizeof
(
*
data
->
prevItemSums
));
if
(
!
data
->
currentItemSums
)
data
->
currentItemSums
=
calloc
(
Meter_getMaxItems
(
this
),
sizeof
(
*
data
->
currentItemSums
));
for
(
int
i
=
0
;
i
<
nValues
;
i
++
)
{
for
(
int
line
=
0
;
line
<
GRAPH_HEIGHT
;
line
++
)
{
data
->
colors
[
i
][
line
]
=
BAR_SHADOW
;
...
...
@@ -413,12 +418,6 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
int
items
=
Meter_getItems
(
this
);
if
(
!
data
->
prevItemSums
)
{
data
->
prevItemSums
=
calloc
(
items
,
sizeof
(
*
data
->
prevItemSums
));
}
if
(
!
data
->
currentItemSums
)
{
data
->
currentItemSums
=
calloc
(
items
,
sizeof
(
*
data
->
currentItemSums
));
}
double
*
prevItemSums
=
data
->
prevItemSums
;
double
*
currentItemSums
=
data
->
currentItemSums
;
...
...
This diff is collapsed.
Click to expand it.
Meter.h
View file @
a94b0466
...
...
@@ -57,6 +57,7 @@ typedef struct MeterClass_ {
#define Meter_defaultMode(this_) As_Meter(this_)->defaultMode
#define Meter_getItems(this_) As_Meter(this_)->curItems
#define Meter_setItems(this_, n_) As_Meter(this_)->curItems = (n_)
#define Meter_getMaxItems(this_) As_Meter(this_)->maxItems
#define Meter_attributes(this_) As_Meter(this_)->attributes
#define Meter_name(this_) As_Meter(this_)->name
#define Meter_uiName(this_) As_Meter(this_)->uiName
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help