From d8d70e07a09a7c50021f6c85690b79b422d43df5 Mon Sep 17 00:00:00 2001 From: spiralman Date: Thu, 16 May 2002 21:14:13 +0000 Subject: fixed segfault when socket() returns -1 (hopefully) --- (limited to 'noncore/tools') diff --git a/noncore/tools/remote/buttondialog.cpp b/noncore/tools/remote/buttondialog.cpp index e7ff4b4..7479e85 100644 --- a/noncore/tools/remote/buttondialog.cpp +++ b/noncore/tools/remote/buttondialog.cpp @@ -98,6 +98,18 @@ QStringList ButtonDialog::getRemotes() strcpy(addr.sun_path,"/dev/lircd"); fd = socket(AF_UNIX, SOCK_STREAM, 0); + if(fd == -1) + { + QMessageBox *mb = new QMessageBox("Error!", + "couldnt connect to socket", + QMessageBox::NoIcon, + QMessageBox::Ok, + QMessageBox::NoButton, + QMessageBox::NoButton); + mb->exec(); + perror("ButtonDialog::GetRemotes"); + return NULL; + } if(std::connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1) { @@ -158,6 +170,19 @@ QStringList ButtonDialog::getButtons(const char *remoteName) write_buffer += '\n'; fd = socket(AF_UNIX, SOCK_STREAM, 0); + if(fd == -1) + { + QMessageBox *mb = new QMessageBox("Error!", + "couldnt connect to socket", + QMessageBox::NoIcon, + QMessageBox::Ok, + QMessageBox::NoButton, + QMessageBox::NoButton); + mb->exec(); + perror("ButtonDialog::GetButtons"); + return NULL; + } + if(std::connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1) { diff --git a/noncore/tools/remote/remotetab.cpp b/noncore/tools/remote/remotetab.cpp index f3a8945..64b8ee4 100644 --- a/noncore/tools/remote/remotetab.cpp +++ b/noncore/tools/remote/remotetab.cpp @@ -51,7 +51,7 @@ RemoteTab::RemoteTab(QWidget *parent=0, const char *name=0):QWidget(parent,name) strcpy(addr.sun_path,"/dev/lircd"); } -void RemoteTab::sendIR() +int RemoteTab::sendIR() { const QObject *button = sender(); QString string = cfg->readEntry(button->name()); @@ -61,6 +61,19 @@ void RemoteTab::sendIR() bool done=false; fd = socket(AF_UNIX, SOCK_STREAM, 0); + if(fd == -1) + { + QMessageBox *mb = new QMessageBox("Error!", + "couldnt connect to socket", + QMessageBox::NoIcon, + QMessageBox::Ok, + QMessageBox::NoButton, + QMessageBox::NoButton); + mb->exec(); + perror("RemoteTab::SendIR"); + return NULL; + } + if(std::connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1) { diff --git a/noncore/tools/remote/remotetab.h b/noncore/tools/remote/remotetab.h index 77a7318..38b58e9 100644 --- a/noncore/tools/remote/remotetab.h +++ b/noncore/tools/remote/remotetab.h @@ -50,7 +50,7 @@ public: void setConfig(Config *newCfg); void updateRemotesList(); public slots: - void sendIR(); + int sendIR(); void remoteSelected(const QString &string); private: int fd; -- cgit v0.9.0.2