dvtm

dynamic virtual terminal manager - with my changes
git clone https://pi.duncano.de/git/dvtm.git
Log | Files | Refs | README | LICENSE

commit 52aadee0a0c7f0040fb05c2f0d5eb99d2052728c
parent 2627553b5ac9596aa094e8a82bd18f48819dbf41
Author: Marc Andre Tanner <mat@brain-dump.org>
Date:   Wed, 13 Mar 2013 17:40:40 +0100

vt: handle malloc(0) == NULL case

The C standard section 7.22.3 states that

 "If the size of the space requested is zero, the behavior is
  implementation-defined"

AIX chooses to return a NULL pointer which we wrongly treated
as an allocation failure.

Signed-off-by: Marc Andre Tanner <mat@brain-dump.org>

Diffstat:
vt.c | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/vt.c b/vt.c @@ -1216,7 +1216,7 @@ static bool buffer_init(Buffer *t, int rows, int cols, int scroll_buf_size) if (scroll_buf_size < 0) scroll_buf_size = 0; t->scroll_buf = scroll_buf = calloc(scroll_buf_size, sizeof(Row)); - if (!scroll_buf) + if (!scroll_buf && scroll_buf_size) goto fail; for (Row *row = scroll_buf, *end = scroll_buf + scroll_buf_size; row < end; row++) { row->cells = calloc(cols, sizeof(Cell));