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.

Signed-off-by: Yin Kangkai <[email protected]>
---
 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 312315b..c194a07 100644
--- a/src/shared/conf-parser.h
+++ b/src/shared/conf-parser.h
@@ -199,7 +199,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;                                   
\
-- 
1.8.2.1

_______________________________________________
systemd-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to