]> granicus.if.org Git - graphviz/commitdiff
fix: do not fclose(NULL) in gvmap
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 29 May 2021 22:29:03 +0000 (15:29 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 5 Jun 2021 02:50:38 +0000 (19:50 -0700)
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.

CHANGELOG.md
cmd/gvmap/country_graph_coloring.c
rtest/test_regression.py

index 0d332277c7ce36a16eea97789ae33bd4858c296a..0be79cedd9fdabe05b894932457b01f341a5374a 100644 (file)
@@ -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
 
index 30e257758151ba4714bb73f047f35dd74aaeb75f..dec42c234eae6dd03b5ed151b539fd1f1418be59 100644 (file)
@@ -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){
index 326340382439b5a48b30d19adf373ac8737eebc1..96849fab8687dd388050fc0d7225f20a4982cdff 100644 (file)
@@ -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():
   """