comparison circbuffer.c @ 709:abd99ecd7ec2

use an empty writebuf rather than a NULL one
author Matt Johnston <matt@ucc.asn.au>
date Wed, 20 Mar 2013 22:31:07 +0800
parents 4222a1039b06
children c71df09bc610
comparison
equal deleted inserted replaced
708:b207d5183bb7 709:abd99ecd7ec2
35 if (size > MAX_CBUF_SIZE) { 35 if (size > MAX_CBUF_SIZE) {
36 dropbear_exit("Bad cbuf size"); 36 dropbear_exit("Bad cbuf size");
37 } 37 }
38 38
39 cbuf = (circbuffer*)m_malloc(sizeof(circbuffer)); 39 cbuf = (circbuffer*)m_malloc(sizeof(circbuffer));
40 cbuf->data = (unsigned char*)m_malloc(size); 40 if (size > 0) {
41 cbuf->data = (unsigned char*)m_malloc(size);
42 }
41 cbuf->used = 0; 43 cbuf->used = 0;
42 cbuf->readpos = 0; 44 cbuf->readpos = 0;
43 cbuf->writepos = 0; 45 cbuf->writepos = 0;
44 cbuf->size = size; 46 cbuf->size = size;
45 47