Skip to content

Commit

Permalink
Fixed crash if s2p contains noise data
Browse files Browse the repository at this point in the history
  • Loading branch information
ra3xdh committed Feb 10, 2024
1 parent a6698e0 commit 1520c03
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 6 additions & 0 deletions qucs/extsimkernels/s2spice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ bool S2Spice::convertTouchstone(QTextStream *stream)

QString next_line;
while(in_stream.readLineInto(&next_line)) {
if (next_line.isEmpty()) continue;
if (next_line.at(0) == '#') break;
}

Expand Down Expand Up @@ -130,6 +131,11 @@ bool S2Spice::convertTouchstone(QTextStream *stream)
while(in_stream.readLineInto(&next_line)) {
if(next_line.isEmpty()) continue;
if(next_line.at(0)=='#') continue;
if(next_line.startsWith("!noise parameters")) {
err_text = "Noise simulation in S2P files is not supported!\n"
"Noise data ignored";
break;
}
if(next_line.at(0)=='!') continue;
tmp_lst = next_line.split(QRegularExpression("[ \\t]"), qucs::SkipEmptyParts);
if (tmp_lst.count() < 2*(ports*ports)+1) {
Expand Down
9 changes: 6 additions & 3 deletions qucs/schematic_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1464,10 +1464,13 @@ bool Schematic::throughAllComps(QTextStream *stream, int& countInit,
S2Spice *conv = new S2Spice();
conv->setFile(f);
conv->setDeviceName(sub_name);
if (!conv->convertTouchstone(stream)) {
QMessageBox::warning(this,tr("Netlist error"),
conv->getErrText());
bool r = conv->convertTouchstone(stream);
QString msg = conv->getErrText();
if (!r) {
QMessageBox::warning(this,tr("Netlist error"), msg);
return false;
} else if (!msg.isEmpty()) {
QMessageBox::warning(this,tr("S2Spice warning"), msg);
}
delete conv;
}
Expand Down

0 comments on commit 1520c03

Please sign in to comment.