forked from osmocom/wireshark
Fix the check for ws_fdopen() failure.
If tf.handle() fails, it returns -1; we shouldn't call ws_fdopen() on its return value. (I'm not sure whether it can fail, but this code is all a bit twisty.) If tf.handle() succeeds, and we hand its return value to ws_fdopen(), and we get back NULL, *that* indicates that ws_fdopen() failed. This should fix Coverity CID 1457929, preventing a FILE leak. Change-Id: I23bb04579d26928037f8b9284b7741affc3596f7 Reviewed-on: https://code.wireshark.org/review/35940 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
8a79d27010
commit
0b64a3afc0
|
@ -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)) {
|
||||
|
|
Loading…
Reference in New Issue