Fixed segfault in jsc compression code

This commit is contained in:
Jordan Sherer 2019-11-25 20:13:00 -05:00
parent b961d03045
commit 88d8070db4
2 changed files with 14 additions and 8 deletions

19
jsc.cpp
View File

@ -112,7 +112,7 @@ QString JSC::decompress(Codeword const& bitvec){
base[7] = base[6] + s*c*c*c*c*c*c;
QList<quint64> bytes;
QList<int> separators;
QList<quint32> separators;
int i = 0;
int count = bitvec.count();
@ -133,22 +133,25 @@ QString JSC::decompress(Codeword const& bitvec){
}
}
int start = 0;
while(start < bytes.length()){
int k = 0;
int j = 0;
quint32 start = 0;
while(start < (quint32)bytes.length()){
quint32 k = 0;
quint32 j = 0;
while(start + k < bytes.length() && bytes[start + k] >= s){
while(start + k < (quint32)bytes.length() && bytes[start + k] >= s){
j = j*c + (bytes[start + k] - s);
k++;
}
if(j >= JSC::size){
break;
}
if(start + k >= bytes.length()){
if(start + k >= (quint32)bytes.length()){
break;
}
j = j*s + bytes[start + k] + base[k];
if(j >= (int)JSC::size){
if(j >= JSC::size){
break;
}

View File

@ -1852,6 +1852,9 @@ void MainWindow::initializeDummyData(){
c.setCharFormat(f);
#endif
// this causes a segfault!
processDecodedLine("223000 -15 -0.3 1681 B 6t++yk+aJbaE 6 \n");
ui->extFreeTextMsgEdit->setPlainText("HELLOBRAVE NEW WORLD");
ui->extFreeTextMsgEdit->setCharsSent(6);