SVN commit 914106 by micron: prevent use of unitialized struct, should help with bug #165548 - kde4 crashes with SIGSEGV during package upgrade M +15 -14 kdirwatch.cpp --- trunk/KDE/kdelibs/kio/kio/kdirwatch.cpp #914105:914106 @@ -342,29 +342,30 @@ } if (event->mask & (IN_DELETE|IN_MOVED_FROM)) { if ((e->isDir) && (!e->m_clients.empty())) { - Client* client = 0; + Client* client = 0; // A file in this directory has been removed. It wasn't an explicitly // watched file as it would have its own watch descriptor, so // no addEntry/ removeEntry bookkeeping should be required. Emit // the event immediately if any clients are interested. KDE_struct_stat stat_buf; QByteArray tpath = QFile::encodeName(e->path+'/'+path); - KDE_stat(tpath, &stat_buf); - bool isDir = S_ISDIR(stat_buf.st_mode); + if (KDE_stat(tpath, &stat_buf) == 0) { + bool isDir = S_ISDIR(stat_buf.st_mode); - KDirWatch::WatchModes flag; - flag = isDir ? KDirWatch::WatchSubDirs : KDirWatch::WatchFiles; + KDirWatch::WatchModes flag; + flag = isDir ? KDirWatch::WatchSubDirs : KDirWatch::WatchFiles; - int counter = 0; - Q_FOREACH(client, e->m_clients) { - if (client->m_watchModes & flag) { - counter++; - } + int counter = 0; + Q_FOREACH(client, e->m_clients) { + if (client->m_watchModes & flag) { + counter++; + } + } + if (counter != 0) + { + emitEvent (e, Deleted, e->path+'/'+path); + } } - if (counter != 0) - { - emitEvent (e, Deleted, e->path+'/'+path); - } } } if (event->mask & (IN_MODIFY|IN_ATTRIB)) {