Merge commit '07f034f07fee5d8f13070488bc38d35c44bafad1' of github.com:CESNET/libyang into ly2_type_plugins
diff --git a/src/plugins_types/binary.c b/src/plugins_types/binary.c
index e4535b4..195548d 100644
--- a/src/plugins_types/binary.c
+++ b/src/plugins_types/binary.c
@@ -220,7 +220,7 @@
 
     if (format == LY_VALUE_LYB) {
         /* allocate the value */
-        val = malloc(sizeof *val);
+        val = calloc(1, sizeof *val);
         LY_CHECK_ERR_GOTO(!val, ret = LY_EMEM, cleanup);
 
         /* init storage */
@@ -256,7 +256,7 @@
     }
 
     /* allocate the value */
-    val = malloc(sizeof *val);
+    val = calloc(1, sizeof *val);
     LY_CHECK_ERR_GOTO(!val, ret = LY_EMEM, cleanup);
 
     /* init storage */
@@ -364,7 +364,7 @@
     ret = lydict_insert(ctx, original->_canonical, ly_strlen(original->_canonical), &dup->_canonical);
     LY_CHECK_RET(ret);
 
-    dup_val = malloc(sizeof *dup_val);
+    dup_val = calloc(1, sizeof *dup_val);
     if (!dup_val) {
         lydict_remove(ctx, dup->_canonical);
         return LY_EMEM;
diff --git a/src/plugins_types/bits.c b/src/plugins_types/bits.c
index bac38e2..7c48c85 100644
--- a/src/plugins_types/bits.c
+++ b/src/plugins_types/bits.c
@@ -309,7 +309,7 @@
         }
 
         /* allocate the value */
-        val = malloc(sizeof *val);
+        val = calloc(1, sizeof *val);
         LY_CHECK_ERR_GOTO(!val, ret = LY_EMEM, cleanup);
 
         /* init storage */
diff --git a/src/plugins_types/decimal64.c b/src/plugins_types/decimal64.c
index bd11313..2b7ab17 100644
--- a/src/plugins_types/decimal64.c
+++ b/src/plugins_types/decimal64.c
@@ -50,7 +50,7 @@
     char *ret;
 
     /* allocate the value */
-    ret = malloc(LY_NUMBER_MAXLEN);
+    ret = calloc(1, LY_NUMBER_MAXLEN);
     LY_CHECK_RET(!ret, LY_EMEM);
 
     if (num) {
diff --git a/src/plugins_types/ipv4_address.c b/src/plugins_types/ipv4_address.c
index 77f5e32..55df218 100644
--- a/src/plugins_types/ipv4_address.c
+++ b/src/plugins_types/ipv4_address.c
@@ -154,7 +154,7 @@
         }
 
         /* allocate the value */
-        val = malloc(sizeof *val);
+        val = calloc(1, sizeof *val);
         LY_CHECK_ERR_GOTO(!val, ret = LY_EMEM, cleanup);
 
         /* init storage */
@@ -339,7 +339,7 @@
     ret = lydict_insert(ctx, original->_canonical, ly_strlen(original->_canonical), &dup->_canonical);
     LY_CHECK_RET(ret);
 
-    dup_val = malloc(sizeof *dup_val);
+    dup_val = calloc(1, sizeof *dup_val);
     if (!dup_val) {
         lydict_remove(ctx, dup->_canonical);
         return LY_EMEM;
diff --git a/src/plugins_types/ipv4_prefix.c b/src/plugins_types/ipv4_prefix.c
index 65ec68e..4811e7a 100644
--- a/src/plugins_types/ipv4_prefix.c
+++ b/src/plugins_types/ipv4_prefix.c
@@ -146,7 +146,7 @@
             val = (void *)value;
             options &= ~LYPLG_TYPE_STORE_DYNAMIC;
         } else {
-            val = malloc(sizeof *val);
+            val = calloc(1, sizeof *val);
             LY_CHECK_ERR_GOTO(!val, ret = LY_EMEM, cleanup);
             memcpy(val, value, value_len);
         }
@@ -179,7 +179,7 @@
     LY_CHECK_GOTO(ret, cleanup);
 
     /* allocate the value */
-    val = malloc(sizeof *val);
+    val = calloc(1, sizeof *val);
     LY_CHECK_ERR_GOTO(!val, ret = LY_EMEM, cleanup);
 
     /* init storage */
@@ -310,7 +310,7 @@
     ret = lydict_insert(ctx, original->_canonical, ly_strlen(original->_canonical), &dup->_canonical);
     LY_CHECK_RET(ret);
 
-    dup_val = malloc(sizeof *dup_val);
+    dup_val = calloc(1, sizeof *dup_val);
     if (!dup_val) {
         lydict_remove(ctx, dup->_canonical);
         return LY_EMEM;
diff --git a/src/plugins_types/ipv6_address.c b/src/plugins_types/ipv6_address.c
index ed320f2..98660d5 100644
--- a/src/plugins_types/ipv6_address.c
+++ b/src/plugins_types/ipv6_address.c
@@ -154,7 +154,7 @@
         }
 
         /* allocate the value */
-        val = malloc(sizeof *val);
+        val = calloc(1, sizeof *val);
         LY_CHECK_ERR_GOTO(!val, ret = LY_EMEM, cleanup);
 
         /* init storage */
@@ -341,7 +341,7 @@
     ret = lydict_insert(ctx, original->_canonical, ly_strlen(original->_canonical), &dup->_canonical);
     LY_CHECK_RET(ret);
 
-    dup_val = malloc(sizeof *dup_val);
+    dup_val = calloc(1, sizeof *dup_val);
     if (!dup_val) {
         lydict_remove(ctx, dup->_canonical);
         return LY_EMEM;
diff --git a/src/plugins_types/ipv6_address_no_zone.c b/src/plugins_types/ipv6_address_no_zone.c
index 6e5995f..da526b1 100644
--- a/src/plugins_types/ipv6_address_no_zone.c
+++ b/src/plugins_types/ipv6_address_no_zone.c
@@ -124,7 +124,7 @@
             options &= ~LYPLG_TYPE_STORE_DYNAMIC;
         } else {
             /* allocate the value */
-            val = malloc(sizeof *val);
+            val = calloc(1, sizeof *val);
             LY_CHECK_ERR_GOTO(!val, ret = LY_EMEM, cleanup);
             storage->ptr = val;
 
@@ -275,7 +275,7 @@
     ret = lydict_insert(ctx, original->_canonical, ly_strlen(original->_canonical), &dup->_canonical);
     LY_CHECK_RET(ret);
 
-    dup_val = malloc(sizeof *dup_val);
+    dup_val = calloc(1, sizeof *dup_val);
     if (!dup_val) {
         lydict_remove(ctx, dup->_canonical);
         return LY_EMEM;
diff --git a/src/plugins_types/ipv6_prefix.c b/src/plugins_types/ipv6_prefix.c
index 7484061..dddd945 100644
--- a/src/plugins_types/ipv6_prefix.c
+++ b/src/plugins_types/ipv6_prefix.c
@@ -148,7 +148,7 @@
             val = (void *)value;
             options &= ~LYPLG_TYPE_STORE_DYNAMIC;
         } else {
-            val = malloc(sizeof *val);
+            val = calloc(1, sizeof *val);
             LY_CHECK_ERR_GOTO(!val, ret = LY_EMEM, cleanup);
             memcpy(val, value, value_len);
         }
@@ -181,7 +181,7 @@
     LY_CHECK_GOTO(ret, cleanup);
 
     /* allocate the value */
-    val = malloc(sizeof *val);
+    val = calloc(1, sizeof *val);
     LY_CHECK_ERR_GOTO(!val, ret = LY_EMEM, cleanup);
 
     /* init storage */
@@ -312,7 +312,7 @@
     ret = lydict_insert(ctx, original->_canonical, ly_strlen(original->_canonical), &dup->_canonical);
     LY_CHECK_RET(ret);
 
-    dup_val = malloc(sizeof *dup_val);
+    dup_val = calloc(1, sizeof *dup_val);
     if (!dup_val) {
         lydict_remove(ctx, dup->_canonical);
         return LY_EMEM;
diff --git a/src/plugins_types/union.c b/src/plugins_types/union.c
index 54291ed..6f1180e 100644
--- a/src/plugins_types/union.c
+++ b/src/plugins_types/union.c
@@ -185,7 +185,7 @@
         subvalue->orig_len = value_len;
         options &= ~LYPLG_TYPE_STORE_DYNAMIC;
     } else {
-        subvalue->original = malloc(value_len);
+        subvalue->original = calloc(1, value_len);
         LY_CHECK_ERR_GOTO(!subvalue->original, ret = LY_EMEM, cleanup);
         memcpy(subvalue->original, value, value_len);
         subvalue->orig_len = value_len;
@@ -326,7 +326,7 @@
     ret = orig_val->value.realtype->plugin->duplicate(ctx, &orig_val->value, &dup_val->value);
     LY_CHECK_GOTO(ret, cleanup);
 
-    dup_val->original = malloc(orig_val->orig_len);
+    dup_val->original = calloc(1, orig_val->orig_len);
     LY_CHECK_ERR_GOTO(!dup_val->original, LOGMEM(ctx); ret = LY_EMEM, cleanup);
     memcpy(dup_val->original, orig_val->original, orig_val->orig_len);
     dup_val->orig_len = orig_val->orig_len;