From 4ae7885c2c4d89e1149c3fb186a4fe3b49787cc7 Mon Sep 17 00:00:00 2001 From: Yin Kangkai Date: Mon, 25 Nov 2013 23:14:46 +0800 Subject: [PATCH] conf-parser: fix memory realloc error Otherwise there is some memory corruption and undefined behavior, e.g., in my case systemd-udev was always aborted at the _cleanup_freep_ around that code blocks. --- src/shared/conf-parser.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h index 42602b3b0..2d5aa31c3 100644 --- a/src/shared/conf-parser.h +++ b/src/shared/conf-parser.h @@ -202,7 +202,7 @@ int log_syntax_internal(const char *unit, int level, continue; \ \ *(xs + i) = x; \ - xs = realloc(xs, ++i + 1); \ + xs = realloc(xs, (++i + 1) * sizeof(type)); \ if (!xs) \ return -ENOMEM; \ *(xs + i) = invalid; \ -- 2.30.2