diff --git a/ui/qt/endpoint_dialog.cpp b/ui/qt/endpoint_dialog.cpp index 7d3003f6ce..bfd3217919 100644 --- a/ui/qt/endpoint_dialog.cpp +++ b/ui/qt/endpoint_dialog.cpp @@ -208,13 +208,23 @@ QUrl EndpointDialog::createMap(bool json_only) return QUrl(); } int fd = tf.handle(); - FILE* fp = ws_fdopen(fd, "wb"); + // + // XXX - QFileDevice.handle() can return -1, but can QTemporaryFile.handle() + // do so if QTemporaryFile.open() has succeeded? + // if (fd == -1) { QMessageBox::warning(this, tr("Map file error"), tr("Unable to create temporary file")); g_free(hosts); tf.remove(); return QUrl(); } + FILE* fp = ws_fdopen(fd, "wb"); + if (fp == NULL) { + QMessageBox::warning(this, tr("Map file error"), tr("Unable to create temporary file")); + g_free(hosts); + tf.remove(); + return QUrl(); + } gchar *err_str; if (!write_endpoint_geoip_map(fp, json_only, hosts, &err_str)) {