* Fixed: [Double free when using libxml2 as regex engine #117](https://github.com/clicon/clixon/issues/117)

* added libxml2 support in test_pattern.sh when libxml2 is configured
This commit is contained in:
Olof hagsand 2020-07-02 13:26:15 +02:00
parent eda4a58ebf
commit 99b01040a7
7 changed files with 29 additions and 10 deletions

View file

@ -984,7 +984,9 @@ xml_yang_validate_add(clicon_handle h,
goto fail;
}
}
if ((ys_cv_validate(h, cv, yt, &reason)) != 1){
if ((ret = ys_cv_validate(h, cv, yt, &reason)) < 0)
goto done;
if (ret == 0){
if (netconf_bad_element_xml(xret, "application", yang_argument_get(yt), reason) < 0)
goto done;
goto fail;

View file

@ -2827,17 +2827,22 @@ yang_type_cache_free(yang_type_cache *ycache)
switch (ycache->yc_rxmode){
case REGEXP_POSIX:
cligen_regex_posix_free(cv_void_get(cv));
if ((p = cv_void_get(cv)) != NULL){
free(p);
cv_void_set(cv, NULL);
}
break;
case REGEXP_LIBXML2:
cligen_regex_libxml2_free(cv_void_get(cv));
/* Note, already freed in libxml2 case */
if ((p = cv_void_get(cv)) != NULL){
cv_void_set(cv, NULL);
}
break;
default:
break;
}
if ((p = cv_void_get(cv)) != NULL){
free(p);
cv_void_set(cv, NULL);
}
}
cvec_free(ycache->yc_regexps);
}