Skip to content
GitLab
Menu
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
71775840
Commit
71775840
authored
Aug 26, 2011
by
Hisham Muhammad
Browse files
Fix segfault in BarMeterMode_draw() for small terminal widths
parent
aa167adb
Changes
2
Show whitespace changes
Inline
Side-by-side
ChangeLog
View file @
71775840
...
@@ -6,6 +6,8 @@ What's new in version 0.9.1
...
@@ -6,6 +6,8 @@ What's new in version 0.9.1
* Meters update in every screen (no longer halting while on Setup, etc.)
* Meters update in every screen (no longer halting while on Setup, etc.)
* BUGFIX: Support larger numbers for process times.
* BUGFIX: Support larger numbers for process times.
(thanks to Tristan Nakagawa for the report.)
(thanks to Tristan Nakagawa for the report.)
* BUGFIX: Segfault in BarMeterMode_draw() for small terminal widths
(patch by Sebastian Pipping)
What's new in version 0.9
What's new in version 0.9
...
...
Meter.c
View file @
71775840
...
@@ -264,13 +264,19 @@ static void BarMeterMode_draw(Meter* this, int x, int y, int w) {
...
@@ -264,13 +264,19 @@ static void BarMeterMode_draw(Meter* this, int x, int y, int w) {
w
--
;
w
--
;
x
++
;
x
++
;
char
bar
[
w
];
if
(
w
<
1
)
{
attrset
(
CRT_colors
[
RESET_COLOR
]);
return
;
}
char
bar
[
w
+
1
];
int
blockSizes
[
10
];
int
blockSizes
[
10
];
for
(
int
i
=
0
;
i
<
w
;
i
++
)
for
(
int
i
=
0
;
i
<
w
;
i
++
)
bar
[
i
]
=
' '
;
bar
[
i
]
=
' '
;
sprintf
(
bar
+
(
w
-
strlen
(
buffer
)),
"%s"
,
buffer
);
const
size_t
barOffset
=
w
-
MIN
(
strlen
(
buffer
),
w
);
snprintf
(
bar
+
barOffset
,
w
-
barOffset
+
1
,
"%s"
,
buffer
);
// First draw in the bar[] buffer...
// First draw in the bar[] buffer...
double
total
=
0
.
0
;
double
total
=
0
.
0
;
...
...
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