mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Cleanup: avoid out of bounds access
This is extremely unlikely to ever happen since we reserve space for a hundred weight models, but hey, doing this right is quite easy, so let's fix it. Found by Coverity. Fixes CID #350117 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
d3d51b175d
commit
4f9783ff60
1 changed files with 2 additions and 2 deletions
|
@ -99,13 +99,13 @@ bool WeightModel::setData(const QModelIndex &index, const QVariant &value, int r
|
||||||
if (!ws->description || gettextFromC::tr(ws->description) != vString) {
|
if (!ws->description || gettextFromC::tr(ws->description) != vString) {
|
||||||
// loop over translations to see if one matches
|
// loop over translations to see if one matches
|
||||||
int i = -1;
|
int i = -1;
|
||||||
while (ws_info[++i].name && i < MAX_WS_INFO) {
|
while (i < MAX_WS_INFO && ws_info[++i].name) {
|
||||||
if (gettextFromC::tr(ws_info[i].name) == vString) {
|
if (gettextFromC::tr(ws_info[i].name) == vString) {
|
||||||
ws->description = copy_string(ws_info[i].name);
|
ws->description = copy_string(ws_info[i].name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ws_info[i].name == NULL) // didn't find a match
|
if (i == MAX_WS_INFO || ws_info[i].name == NULL) // didn't find a match
|
||||||
ws->description = copy_qstring(vString);
|
ws->description = copy_qstring(vString);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue