Skip to content

Commit

Permalink
lvxml: fix cppcheck warning
Browse files Browse the repository at this point in the history
```
lvxml.cpp|6166 col 42| warning: Uninitialized variable: quote [uninitvar]
    int endpos = encname.pos(quote);

lvxml.cpp|6159 col 28| note: Assuming condition is false
    while (pos < end) {

lvxml.cpp|6166 col 42| note: Uninitialized variable: quote
    int endpos = encname.pos(quote);
```
  • Loading branch information
benoit-pierre authored and poire-z committed Jul 28, 2024
1 parent bb2c7e6 commit 159aeef
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions crengine/src/lvxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6153,21 +6153,14 @@ bool LVHTMLParser::CheckFormat()
// see https://html.spec.whatwg.org/multipage/parsing.html#concept-get-attributes-when-sniffing
int encpos = s.pos("encoding=");
if ( encpos >= 0 ) {
int pos = encpos + 9;
int startpos, endpos;
int end = s.length();
lChar8 quote;
while (pos < end) {
quote = s[pos];
if (quote == '\'' || quote == '\"')
for (startpos = encpos + 9; startpos < end; ++startpos)
if (s[startpos] == '\'' || s[startpos] == '\"')
break;
++pos;
}
lString8 encname = s.substr(pos + 1, 20 );
int endpos = encname.pos(quote);
if ( endpos>0 ) {
encname.erase( endpos, encname.length() - endpos );
lString32 enc32(encname.c_str());
SetCharset(enc32.c_str());
endpos = s.pos(s[startpos], startpos + 1);
if (endpos > startpos) {
SetCharset(lString32(s.c_str() + startpos + 1, endpos - startpos - 1).c_str());
charset_found = true;
}
}
Expand Down

0 comments on commit 159aeef

Please sign in to comment.