From: Matthew Fernandez Date: Sat, 29 May 2021 22:29:03 +0000 (-0700) Subject: fix: do not fclose(NULL) in gvmap X-Git-Tag: 2.47.3~14^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=260f20a43cf1d7803157daddeb5e034a025efa58;p=graphviz fix: do not fclose(NULL) in gvmap gvmap opens a debugging file to write timing information to if verbosity is enabled. It tried to unconditionally close this file, regardless of whether verbosity was enabled. The result was that, without verbosity enabled, it would call fclose(NULL). The effect of this seems to vary across operating systems but can result in a crash. This fix only tries to close the file if it was previously opened. Related to #1822. Unfortunately we cannot un-xfail test_gvmap_fclose because it fails for another reason on some platforms. --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d332277c..0be79cedd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 characters - out of bounds read when examining a registered plugin whose name is ≥63 characters +- do not `fclose(NULL)` in gvmap ## [2.47.2] - 2021-05-26 diff --git a/cmd/gvmap/country_graph_coloring.c b/cmd/gvmap/country_graph_coloring.c index 30e257758..dec42c234 100644 --- a/cmd/gvmap/country_graph_coloring.c +++ b/cmd/gvmap/country_graph_coloring.c @@ -264,7 +264,9 @@ void improve_antibandwidth_by_swapping(SparseMatrix A, int *p){ fprintf(fp,"%f %f %f\n", (real) (clock() - start)/(CLOCKS_PER_SEC), norm1[0], norm1[2]); } } - fclose(fp); + if (fp != NULL) { + fclose(fp); + } } static void country_graph_coloring_internal(int seed, SparseMatrix A, int **p, real *norm_1, int do_swapping){ diff --git a/rtest/test_regression.py b/rtest/test_regression.py index 326340382..96849fab8 100644 --- a/rtest/test_regression.py +++ b/rtest/test_regression.py @@ -949,7 +949,7 @@ def test_vcxproj_inclusive(vcxproj: Path): assert srcs1 == srcs2, \ "mismatch between sources in {str(vcxproj)} and {str(filters)}" -@pytest.mark.xfail() +@pytest.mark.xfail() # FIXME: fails on CentOS 7/8, macOS Autotools, MSBuild @pytest.mark.skipif(shutil.which("gvmap") is None, reason="gvmap not available") def test_gvmap_fclose(): """