From 77efcf8bdd14cd19dc445cf6e44bba7af414939c Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 8 Oct 2014 17:14:04 +0000 Subject: Use xrealloc(NULL, n, m) instead of xmalloc(n * m) to get overflow check. --- paste.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'paste.c') 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); -- cgit v1.2.3 From a27ba6e38006c12c48de88600b8cff9f6aabfed7 Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 8 Oct 2014 17:35:58 +0000 Subject: Add xreallocarray and remove nmemb argument from xrealloc. --- paste.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'paste.c') diff --git a/paste.c b/paste.c index 603adda6..0332e60e 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 = xrealloc(NULL, len, 4 + 4); + buf = xreallocarray(NULL, len, 4 + 4); if (utf8flag) used = utf8_strvis(buf, pb->data, len, flags); -- cgit v1.2.3