[wiki] [sites] fixed a malloc issue in dwmstatus volume display || Andrew Milkovich

From: <git_AT_suckless.org>
Date: Fri, 25 Jan 2013 21:18:19 +0100

commit ff99817d48008d70d419d92d7a4e34bac0a35875
Author: Andrew Milkovich <amilkovich_AT_gmail.com>
Date: Fri Jan 25 12:17:46 2013 -0800

    fixed a malloc issue in dwmstatus volume display

diff --git a/dwm.suckless.org/dwmstatus/p1c0-dwmstatus-volume.c b/dwm.suckless.org/dwmstatus/p1c0-dwmstatus-volume.c
index a9ac939..dedd4de 100644
--- a/dwm.suckless.org/dwmstatus/p1c0-dwmstatus-volume.c
+++ b/dwm.suckless.org/dwmstatus/p1c0-dwmstatus-volume.c
_AT_@ -141,13 +141,13 @@ setvolume(int percent) {
 char*
 mkprogressbar(unsigned int size, unsigned int percent) {
         unsigned int num = ((size-2)*percent)/100;
- char *bar = malloc(size);
+ char *bar = malloc(size+1);
         if (bar == NULL) {
                 perror("malloc");
                 exit(1);
         }
         bar[0] = '[';
- for (int i = 1; i <= num; i++) {
+ for (int i = 1; i < num+1; i++) {
               bar[i] = '*';
         }
         for (int i = num+1; i < size-1; i++) {
Received on Fri Jan 25 2013 - 21:18:19 CET

This archive was generated by hypermail 2.3.0 : Fri Jan 25 2013 - 21:24:07 CET