summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm>2014-10-08 17:14:04 +0000
committernicm <nicm>2014-10-08 17:14:04 +0000
commit77efcf8bdd14cd19dc445cf6e44bba7af414939c (patch)
tree7072113ef40d5ef7ac2206e7014b7c510d02fe18
parent6610e89689de1ba8afe492ad20b541271d39732d (diff)
Use xrealloc(NULL, n, m) instead of xmalloc(n * m) to get overflow
check.
-rw-r--r--grid.c3
-rw-r--r--paste.c2
2 files changed, 3 insertions, 2 deletions
diff --git a/grid.c b/grid.c
index afb0e041..b2351b28 100644
--- a/grid.c
+++ b/grid.c
@@ -724,7 +724,8 @@ grid_reflow_split(struct grid *dst, u_int *py, struct grid_line *src_gl,
to_copy = src_gl->cellsize;
/* Expand destination line. */
- dst_gl->celldata = xmalloc(to_copy * sizeof *dst_gl->celldata);
+ dst_gl->celldata = xrealloc(NULL, to_copy,
+ sizeof *dst_gl->celldata);
dst_gl->cellsize = to_copy;
dst_gl->flags |= GRID_LINE_WRAPPED;
diff --git a/paste.c b/paste.c
index e8ea0c34..603adda6 100644
--- a/paste.c
+++ b/paste.c
@@ -279,7 +279,7 @@ paste_make_sample(struct paste_buffer *pb, int utf8flag)
len = pb->size;
if (len > width)
len = width;
- buf = xmalloc(len * 4 + 4);
+ buf = xrealloc(NULL, len, 4 + 4);
if (utf8flag)
used = utf8_strvis(buf, pb->data, len, flags);