Ticket #14067: 14067_invalid_free.patch

File 14067_invalid_free.patch, 2.2 KB (added by jdemeyer, 9 years ago)
  • sage/graphs/generic_graph_pyx.pyx

    # HG changeset patch
    # User Jeroen Demeyer <jdemeyer@cage.ugent.be>
    # Date 1360146485 -3600
    # Node ID ef88faccc33ce603287bd8f07a7e37394cc125d2
    # Parent  6ce56d7a6b0421400ee8b134cf9d83744dc41ce7
    Fix initialization of SubgraphSearch objects
    
    diff --git a/sage/graphs/generic_graph_pyx.pyx b/sage/graphs/generic_graph_pyx.pyx
    a b  
    491491            sage: g.subgraph_search(graphs.CycleGraph(5))
    492492            Subgraph of (Petersen graph): Graph on 5 vertices
    493493
    494         TESTS::
     494        TESTS:
     495
     496        Test proper initialization and deallocation, see :trac:`14067`.
     497        We intentionally only create the class without doing any
     498        computations with it::
    495499
    496500            sage: from sage.graphs.generic_graph_pyx import SubgraphSearch
    497             sage: SubgraphSearch(Graph(5),Graph(1))
     501            sage: SubgraphSearch(Graph(5), Graph(1))
    498502            Traceback (most recent call last):
    499503            ...
    500504            ValueError: Searched graph should have at least 2 vertices.
     505            sage: SubgraphSearch(Graph(5), Graph(2))
     506            <sage.graphs.generic_graph_pyx.SubgraphSearch ...>
    501507        """
    502508        if H.order() <= 1:
    503509            raise ValueError("Searched graph should have at least 2 vertices.")
     
    505511        if sum([G.is_directed(), H.is_directed()]) == 1:
    506512            raise ValueError("One graph can not be directed while the other is not.")
    507513
     514        self._initialization()
     515
    508516    def __iter__(self):
    509517        r"""
    510518        Returns an iterator over all the labeleld subgraphs of `G`
     
    626634        self.ng = G.order()
    627635        self.nh = H.order()
    628636
    629 
    630 
    631637        # Storing the list of vertices
    632638        self.g_vertices = G.vertices()
    633639
    634         # Are the graphs directed (at the end of the code is checked
     640        # Are the graphs directed (in __init__(), we check
    635641        # whether both are of the same type)
    636642        self.directed = G.is_directed()
    637643
     
    689695            for 0 <= i < self.nh:
    690696                self.line_h_in[i] = <int *>self.h.adjacency_sequence_in(i, self.vertices, i)
    691697
    692         self._initialization()
    693 
    694698    def __next__(self):
    695699        r"""
    696700        Returns the next isomorphic subgraph if any, and raises a