PengZheng opened a new issue, #512:
URL: https://github.com/apache/celix/issues/512
```C
celix_version_t* celix_utils_convertStringToVersion(const char* val, const
celix_version_t* defaultValue, bool* converted) {
celix_version_t* result = NULL;
if (val != NULL) {
//check if string has two dots ('.'), and only try to create string
if it has two dots
char* firstDot = strchr(val, '.');
char* lastDot = strrchr(val, '.');
if (firstDot != NULL && lastDot != NULL && firstDot != lastDot) {
char buf[64];
char* valCopy = celix_utils_writeOrCreateString(buf,
sizeof(buf), "%s", val);
valCopy = celix_utils_trim(valCopy);
result = celix_version_createVersionFromString(valCopy);
celix_utils_freeStringIfNotEqual(buf, valCopy);
}
}
if (converted) {
*converted = result != NULL;
}
if (result == NULL && defaultValue != NULL) {
result = celix_version_copy(defaultValue);
}
return result;
}
```
`celix_utils_trim` returns a copy of valCopy, thus the original valCopy (if
allocated) is leaked.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]