mirror of
https://github.com/vcmi/vcmi.git
synced 2025-05-13 22:06:58 +02:00
Fixed possible buffer overflow on visiting tavern
Introduction of unicode made fixed-length buffers too short in some cases
This commit is contained in:
parent
55a4561926
commit
e101caa997
@ -3782,7 +3782,7 @@ void CTavernWindow::show(SDL_Surface * to)
|
|||||||
boost::algorithm::replace_first(recruit->hoverTexts[0],"%s",sel->h->type->heroClass->name);
|
boost::algorithm::replace_first(recruit->hoverTexts[0],"%s",sel->h->type->heroClass->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
printAtMiddleWBLoc(sel->descr, 146, 395, FONT_SMALL, 200, Colors::WHITE, to);
|
printAtMiddleWBLoc(sel->description, 146, 395, FONT_SMALL, 200, Colors::WHITE, to);
|
||||||
CSDL_Ext::drawBorder(to,sel->pos.x-2,sel->pos.y-2,sel->pos.w+4,sel->pos.h+4,int3(247,223,123));
|
CSDL_Ext::drawBorder(to,sel->pos.x-2,sel->pos.y-2,sel->pos.w+4,sel->pos.h+4,int3(247,223,123));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3821,9 +3821,12 @@ CTavernWindow::HeroPortrait::HeroPortrait(int &sel, int id, int x, int y, const
|
|||||||
for(int i=13; i<=17; i++) //war machines and spellbook don't count
|
for(int i=13; i<=17; i++) //war machines and spellbook don't count
|
||||||
if(vstd::contains(h->artifactsWorn, ArtifactPosition(i)))
|
if(vstd::contains(h->artifactsWorn, ArtifactPosition(i)))
|
||||||
artifs--;
|
artifs--;
|
||||||
sprintf_s(descr, sizeof(descr),CGI->generaltexth->allTexts[215].c_str(),
|
|
||||||
h->name.c_str(), h->level, h->type->heroClass->name.c_str(), artifs);
|
description = CGI->generaltexth->allTexts[215];
|
||||||
descr[sizeof(descr)-1] = '\0';
|
boost::algorithm::replace_first(description, "%s", h->name);
|
||||||
|
boost::algorithm::replace_first(description, "%d", boost::lexical_cast<std::string>(h->level));
|
||||||
|
boost::algorithm::replace_first(description, "%s", h->type->heroClass->name);
|
||||||
|
boost::algorithm::replace_first(description, "%d", boost::lexical_cast<std::string>(artifs));
|
||||||
|
|
||||||
new CAnimImage("portraitsLarge", h->portrait);
|
new CAnimImage("portraitsLarge", h->portrait);
|
||||||
}
|
}
|
||||||
|
@ -790,8 +790,8 @@ public:
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::string hoverName;
|
std::string hoverName;
|
||||||
|
std::string description; // "XXX is a level Y ZZZ with N artifacts"
|
||||||
const CGHeroInstance *h;
|
const CGHeroInstance *h;
|
||||||
char descr[100]; // "XXX is a level Y ZZZ with N artifacts"
|
|
||||||
|
|
||||||
void clickLeft(tribool down, bool previousState);
|
void clickLeft(tribool down, bool previousState);
|
||||||
void clickRight(tribool down, bool previousState);
|
void clickRight(tribool down, bool previousState);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user