diff options
author | Sebastian Pipping <sping@gentoo.org> | 2011-08-26 21:37:18 +0000 |
---|---|---|
committer | Sebastian Pipping <sping@gentoo.org> | 2011-08-26 21:37:18 +0000 |
commit | 55ed9eb59acbe457df542b484e5b9b9ba07c937e (patch) | |
tree | 5aa479859ba4ba54ccde0cedd48d22cc103e5a6b /sys-process/htop/files/htop-0.9-small-width.patch | |
parent | Revbump to combine the gconf and gnome-keyring USE flags under the gnome USE ... (diff) | |
download | gentoo-2-55ed9eb59acbe457df542b484e5b9b9ba07c937e.tar.gz gentoo-2-55ed9eb59acbe457df542b484e5b9b9ba07c937e.tar.bz2 gentoo-2-55ed9eb59acbe457df542b484e5b9b9ba07c937e.zip |
sys-process/htop: Integrate post-0.9 bugfix patch
(Portage version: 2.1.10.11/cvs/Linux x86_64)
Diffstat (limited to 'sys-process/htop/files/htop-0.9-small-width.patch')
-rw-r--r-- | sys-process/htop/files/htop-0.9-small-width.patch | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/sys-process/htop/files/htop-0.9-small-width.patch b/sys-process/htop/files/htop-0.9-small-width.patch new file mode 100644 index 000000000000..743111137b03 --- /dev/null +++ b/sys-process/htop/files/htop-0.9-small-width.patch @@ -0,0 +1,42 @@ +From 17d258ff0a216dd87655c8e93d065e5e6c504f42 Mon Sep 17 00:00:00 2001 +From: Sebastian Pipping <sebastian@pipping.org> +Date: Mon, 1 Aug 2011 02:51:24 +0200 +Subject: [PATCH 3/3] Fix segfault in BarMeterMode_draw() for small terminal + widths + +Segfault can be triggered by running "COLUMNS=1 ./htop" +For me, COLUMNS=40 was the first that would not crash. +--- + ChangeLog | 2 ++ + Meter.c | 11 +++++++++-- + 2 files changed, 11 insertions(+), 2 deletions(-) + +diff --git a/Meter.c b/Meter.c +index 6947d9b..408b981 100644 +--- a/Meter.c ++++ b/Meter.c +@@ -264,13 +265,19 @@ static void BarMeterMode_draw(Meter* this, int x, int y, int w) { + + w--; + x++; +- char bar[w]; ++ ++ if (w < 1) { ++ attrset(CRT_colors[RESET_COLOR]); ++ return; ++ } ++ char bar[w + 1]; + + int blockSizes[10]; + for (int i = 0; i < w; i++) + bar[i] = ' '; + +- sprintf(bar + (w-strlen(buffer)), "%s", buffer); ++ const size_t bar_offset = w - MIN(strlen(buffer), w); ++ snprintf(bar + bar_offset, w - bar_offset + 1, "%s", buffer); + + // First draw in the bar[] buffer... + double total = 0.0; +-- +1.7.6 + |