33 lines
967 B
Diff
33 lines
967 B
Diff
From fbf963dde2cbe34dba1df269b9506f4a55c39357 Mon Sep 17 00:00:00 2001
|
|
From: Tomas Mraz <tmraz@fedoraproject.org>
|
|
Date: Mon, 22 Oct 2018 16:29:31 +0200
|
|
Subject: [PATCH] Use calloc() instead of malloc() in distcalculate to
|
|
initialize the memory.
|
|
|
|
---
|
|
src/check.c | 4 ++--
|
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/src/check.c b/src/check.c
|
|
index ac7cbd5..61218a7 100644
|
|
--- a/src/check.c
|
|
+++ b/src/check.c
|
|
@@ -96,12 +96,12 @@ distance(const char *old, const char *new)
|
|
|
|
m = strlen(old);
|
|
n = strlen(new);
|
|
- distances = malloc(sizeof(int*) * (m + 1));
|
|
+ distances = calloc(m + 1, sizeof(int*));
|
|
if (distances == NULL)
|
|
return -1;
|
|
|
|
for (i = 0; i <= m; i++) {
|
|
- distances[i] = malloc(sizeof(int) * (n + 1));
|
|
+ distances[i] = calloc(n + 1, sizeof(int));
|
|
if (distances[i] == NULL)
|
|
goto allocfail;
|
|
|
|
--
|
|
2.14.5
|
|
|