Cleanup: Fix Problems Raised by Coverity Scan.

Opportunistically fix some problems newly raised by a recent Coverity
scan.

Not touching any of the string memory allocation issues as this is being
handled by the move towards C++ strings.

Signed-off-by: Michael Keller <mikeller@042.ch>
This commit is contained in:
Michael Keller 2024-03-13 13:11:34 +13:00 committed by Michael Keller
parent 3229d1e3a1
commit e6ff3f7537
3 changed files with 11 additions and 10 deletions

View file

@ -452,11 +452,12 @@ static std::string parse_mkvi_value(const char *haystack, const char *needle)
if ((lineptr = strstr(haystack, needle)) != NULL) {
if ((valueptr = strstr(lineptr, ": ")) != NULL) {
valueptr += 2;
}
if ((endptr = strstr(lineptr, "\n")) != NULL) {
if (*(endptr - 1) == '\r')
--endptr;
return std::string(valueptr, endptr - valueptr);
if ((endptr = strstr(lineptr, "\n")) != NULL) {
if (*(endptr - 1) == '\r')
--endptr;
return std::string(valueptr, endptr - valueptr);
}
}
}
return std::string();