Fix crash when MathMatrix has more than 80 columns
Patch from John McCabe-Dansted, approved from Andre.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33641
a592a061-630c-0410-9148-
cb99ea01b6c8
int pattern_index = 0;
int table_index = 0;
- char pattern[20];
+ char pattern[22]; // 20 + 1 for pattern[20], + 1 for '\0'
number_index = 1;
unit_index = 1; // entries at index 0 are sentinels
// construct "pattern" from "data"
while (!isEndOfData(buffer)) {
- if (pattern_index > 20)
+ if (pattern_index > (sizeof(pattern) - 2))
return false;
pattern[pattern_index] = nextToken(buffer);
if (pattern[pattern_index] == 'E')
void noAppDialog(QString const & title, QString const & msg, QMessageBox::Icon mode)
{
int argc = 1;
- char * argv[1];
- QApplication app(argc, argv);
+ const char *argv[] = { "lyx", 0 };
+
+ QApplication app(argc, (char**)argv);
switch (mode)
{
case QMessageBox::Information: QMessageBox::information(0, title, msg); break;
void GuiMathMatrix::columnsChanged(int)
{
- char h_align_str[80] = "c";
int const nx = int(columnsSB->value());
- for (int i = 0; i < nx; ++i)
- h_align_str[i] = 'c';
-
- h_align_str[nx] = '\0';
- halignED->setText(h_align_str);
+ halignED->setText(QString(nx, 'c'));
}
bool readLink(FileName const & file, FileName & link)
{
#ifdef HAVE_READLINK
- char linkbuffer[512];
- // Should be PATH_MAX but that needs autconf support
+ char linkbuffer[PATH_MAX + 1];
string const encoded = file.toFilesystemEncoding();
int const nRead = ::readlink(encoded.c_str(),
linkbuffer, sizeof(linkbuffer) - 1);