aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'xf86drmMode.c')
-rw-r--r--xf86drmMode.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/xf86drmMode.c b/xf86drmMode.c
index e1c99742..2876b422 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -1507,7 +1507,7 @@ drmModeAtomicReqPtr drmModeAtomicDuplicate(drmModeAtomicReqPtr old)
1507 return NULL; 1507 return NULL;
1508 } 1508 }
1509 memcpy(new->items, old->items, 1509 memcpy(new->items, old->items,
1510 old->size_items * sizeof(*new->items)); 1510 old->cursor * sizeof(*new->items));
1511 } else { 1511 } else {
1512 new->items = NULL; 1512 new->items = NULL;
1513 } 1513 }
@@ -1566,12 +1566,13 @@ int drmModeAtomicAddProperty(drmModeAtomicReqPtr req,
1566 return -EINVAL; 1566 return -EINVAL;
1567 1567
1568 if (req->cursor >= req->size_items) { 1568 if (req->cursor >= req->size_items) {
1569 const uint32_t item_size_inc = getpagesize() / sizeof(*req->items);
1569 drmModeAtomicReqItemPtr new; 1570 drmModeAtomicReqItemPtr new;
1570 1571
1571 req->size_items += 16; 1572 req->size_items += item_size_inc;
1572 new = realloc(req->items, req->size_items * sizeof(*req->items)); 1573 new = realloc(req->items, req->size_items * sizeof(*req->items));
1573 if (!new) { 1574 if (!new) {
1574 req->size_items -= 16; 1575 req->size_items -= item_size_inc;
1575 return -ENOMEM; 1576 return -ENOMEM;
1576 } 1577 }
1577 req->items = new; 1578 req->items = new;