Skip to content

Commit

Permalink
Segfault when using grep fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
ruben2020 committed Mar 31, 2020
1 parent 28c42b3 commit 41d0e48
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
6 changes: 3 additions & 3 deletions doc/INSTALL-LINUX.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ Step 1: Install CMake (>2.7), sqlite3, Qt4 (>4.7) or Qt5 (>5.7) for Qt4 or Qt5,

In Ubuntu or Linux Mint or Debian, do the following (first line for Qt5 OR second line for Qt4 OR third line for no GUI):
```bash
sudo apt-get install g++ git cmake sqlite3 libsqlite3-dev qt5-default qttools5-dev-tools qttools5-dev cscope exuberant-ctags
sudo apt-get install g++ git cmake sqlite3 libsqlite3-dev qt4-dev-tools cscope exuberant-ctags
sudo apt-get install g++ git cmake sqlite3 libsqlite3-dev cscope exuberant-ctags
sudo apt-get install build-essential g++ git cmake sqlite3 libsqlite3-dev qt5-default qttools5-dev-tools qttools5-dev cscope exuberant-ctags
sudo apt-get install build-essential g++ git cmake sqlite3 libsqlite3-dev qt4-dev-tools cscope exuberant-ctags
sudo apt-get install build-essential g++ git cmake sqlite3 libsqlite3-dev cscope exuberant-ctags
```

In Arch Linux or Manjaro or Apricity, do the following (first line for Qt5 OR second line for Qt4 OR third line for no GUI):
Expand Down
2 changes: 1 addition & 1 deletion gui/searchhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ sqlqueryresultlist searchhandler::doGrep(const QString &fp)
QString str, fp2;
tStr fpstr, fn;
long pos, linenumber=0;
char numtext[10];
char numtext[30];
QRegExp rx1(*m_grepRegExp);
reslist.result_type = sqlqueryresultlist::sqlresultFILE_LINE;
fp2 = fp;
Expand Down
11 changes: 8 additions & 3 deletions querylib/small_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,16 @@ bool isAbsolutePath(tStr fp)
bool strrevcmp(tStr str, tStr cmpstr)
{
bool retval = (1 == 1);
unsigned int n = str.length();
size_t n = str.length();
if (n != cmpstr.length()) {retval = (1 == 0);}
else for (unsigned int i = (n - 1); i >= 0; i--)
else if (n > 0)
for (size_t i = (n - 1); ((i >= 0)&&(i < n)); i--)
{
if (str[i] != cmpstr[i])
if ((i < 0)||(i >= n))
{
continue;
}
if (str.CHAR_AT(i) != cmpstr.CHAR_AT(i))
{
retval = (1 == 0);
break;
Expand Down
3 changes: 3 additions & 0 deletions querylib/small_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,20 @@ typedef std::set<std::string> tSetStr;
#define C_STR(x) toLatin1(x).data(x)
#define STRISEMPTY(x) isEmpty(x)
#define STRTOLOWER(x,y) x = y.toLower()
#define CHAR_AT(x) at(x).toLatin1()

#elif defined(USE_QT4) // use Qt4's QString
#define C_STR(x) toAscii(x).data(x)
#define STRISEMPTY(x) isEmpty(x)
#define STRTOLOWER(x,y) x = y.toLower()
#define CHAR_AT(x) at(x).toLatin1()

#else // use std::string
#define C_STR(x) c_str(x)
#define STRISEMPTY(x) empty(x)
#define STRTOLOWER(x,y) x = y; \
std::transform(x.begin(), x.end(), x.begin(), ::tolower)
#define CHAR_AT(x) at(x)
#endif


Expand Down

0 comments on commit 41d0e48

Please sign in to comment.