summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fitz/dev_text.c2
-rw-r--r--fitz/obj_array.c2
-rw-r--r--fitz/obj_dict.c2
-rw-r--r--fitz/stm_buffer.c2
-rw-r--r--mupdf/pdf_cmap.c4
5 files changed, 7 insertions, 5 deletions
diff --git a/fitz/dev_text.c b/fitz/dev_text.c
index e23479e9..2cd4ab11 100644
--- a/fitz/dev_text.c
+++ b/fitz/dev_text.c
@@ -69,7 +69,7 @@ fz_addtextcharimp(fz_textspan *span, int c, fz_bbox bbox)
{
if (span->len + 1 >= span->cap)
{
- span->cap = span->cap ? (span->cap * 3) / 2 : 80;
+ span->cap = span->cap > 1 ? (span->cap * 3) / 2 : 80;
span->text = fz_realloc(span->text, sizeof(fz_textchar) * span->cap);
}
span->text[span->len].c = c;
diff --git a/fitz/obj_array.c b/fitz/obj_array.c
index 0b42e8c4..d7d2d2e7 100644
--- a/fitz/obj_array.c
+++ b/fitz/obj_array.c
@@ -11,7 +11,7 @@ fz_newarray(int initialcap)
obj->kind = FZ_ARRAY;
obj->u.a.len = 0;
- obj->u.a.cap = initialcap > 0 ? initialcap : 6;
+ obj->u.a.cap = initialcap > 1 ? initialcap : 6;
obj->u.a.items = fz_malloc(sizeof (fz_obj*) * obj->u.a.cap);
for (i = 0; i < obj->u.a.cap; i++)
diff --git a/fitz/obj_dict.c b/fitz/obj_dict.c
index 96e5dbff..af80226c 100644
--- a/fitz/obj_dict.c
+++ b/fitz/obj_dict.c
@@ -30,7 +30,7 @@ fz_newdict(int initialcap)
obj->u.d.sorted = 1;
obj->u.d.len = 0;
- obj->u.d.cap = initialcap > 0 ? initialcap : 10;
+ obj->u.d.cap = initialcap > 1 ? initialcap : 10;
obj->u.d.items = fz_malloc(sizeof(fz_keyval) * obj->u.d.cap);
for (i = 0; i < obj->u.d.cap; i++)
diff --git a/fitz/stm_buffer.c b/fitz/stm_buffer.c
index 58c69996..f7da8289 100644
--- a/fitz/stm_buffer.c
+++ b/fitz/stm_buffer.c
@@ -5,6 +5,8 @@ fz_newbuffer(int size)
{
fz_buffer *b;
+ size = size > 1 ? size : 16;
+
b = fz_malloc(sizeof(fz_buffer));
b->refs = 1;
b->ownsdata = 1;
diff --git a/mupdf/pdf_cmap.c b/mupdf/pdf_cmap.c
index ba1680f1..1d173e3e 100644
--- a/mupdf/pdf_cmap.c
+++ b/mupdf/pdf_cmap.c
@@ -181,7 +181,7 @@ addtable(pdf_cmap *cmap, int value)
{
if (cmap->tlen + 1 > cmap->tcap)
{
- cmap->tcap = cmap->tcap == 0 ? 256 : (cmap->tcap * 3) / 2;
+ cmap->tcap = cmap->tcap > 1 ? (cmap->tcap * 3) / 2 : 256;
cmap->table = fz_realloc(cmap->table, cmap->tcap * sizeof(unsigned short));
}
cmap->table[cmap->tlen++] = value;
@@ -195,7 +195,7 @@ addrange(pdf_cmap *cmap, int low, int high, int flag, int offset)
{
if (cmap->rlen + 1 > cmap->rcap)
{
- cmap->rcap = cmap->rcap == 0 ? 256 : (cmap->rcap * 3) / 2;
+ cmap->rcap = cmap->rcap > 1 ? (cmap->rcap * 3) / 2 : 256;
cmap->ranges = fz_realloc(cmap->ranges, cmap->rcap * sizeof(pdf_range));
}
cmap->ranges[cmap->rlen].low = low;