aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--xf86drmMode.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/xf86drmMode.c b/xf86drmMode.c
index 9a15b5e7..b0ec609b 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -1250,7 +1250,7 @@ drmModeAtomicReqPtr drmModeAtomicDuplicate(drmModeAtomicReqPtr old)
1250 return NULL; 1250 return NULL;
1251 } 1251 }
1252 memcpy(new->items, old->items, 1252 memcpy(new->items, old->items,
1253 old->size_items * sizeof(*new->items)); 1253 old->cursor * sizeof(*new->items));
1254 } else { 1254 } else {
1255 new->items = NULL; 1255 new->items = NULL;
1256 } 1256 }
@@ -1312,12 +1312,13 @@ int drmModeAtomicAddProperty(drmModeAtomicReqPtr req,
1312 return -EINVAL; 1312 return -EINVAL;
1313 1313
1314 if (req->cursor >= req->size_items) { 1314 if (req->cursor >= req->size_items) {
1315 const uint32_t item_size_inc = getpagesize() / sizeof(*req->items);
1315 drmModeAtomicReqItemPtr new; 1316 drmModeAtomicReqItemPtr new;
1316 1317
1317 req->size_items += 16; 1318 req->size_items += item_size_inc;
1318 new = realloc(req->items, req->size_items * sizeof(*req->items)); 1319 new = realloc(req->items, req->size_items * sizeof(*req->items));
1319 if (!new) { 1320 if (!new) {
1320 req->size_items -= 16; 1321 req->size_items -= item_size_inc;
1321 return -ENOMEM; 1322 return -ENOMEM;
1322 } 1323 }
1323 req->items = new; 1324 req->items = new;