Limit overallocation to [8-256] bytes
This commit is contained in:
+2
-1
@@ -3,6 +3,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "ucore/buffer.h"
|
#include "ucore/buffer.h"
|
||||||
|
#include "ucore/utils.h"
|
||||||
|
|
||||||
GBuf*
|
GBuf*
|
||||||
uc_new_gbuf(size_t initsz)
|
uc_new_gbuf(size_t initsz)
|
||||||
@@ -48,7 +49,7 @@ uc_gbuf_append(GBuf *buf,const void *data,size_t len)
|
|||||||
unsigned char *gbuf;
|
unsigned char *gbuf;
|
||||||
|
|
||||||
if (buf->len - buf->used < len)
|
if (buf->len - buf->used < len)
|
||||||
if (uc_gbuf_grow(buf, len + len/2))
|
if (uc_gbuf_grow(buf, len + UC_MAX(UC_MIN(8U,len/2),256U)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
gbuf = buf->buf;
|
gbuf = buf->buf;
|
||||||
|
|||||||
Reference in New Issue
Block a user