Ticket #4067: trac_4067.patch

File trac_4067.patch, 1.3 KB (added by mabshoff, 13 years ago)
  • sage/stats/hmm/chmm.pyx

    # HG changeset patch
    # User mabshoff@sage.math.washington.edu
    # Date 1220609297 25200
    # Node ID 312dba7e2116a398698514f8b0720543efeaec47
    # Parent  d68efaaa2ff9dd9fc0e98e2deb80b430853ba247
    C Strings are NULL terminated, so allocate enough space in hmm.pyx and ghmm.pyx (#4067)
    
    diff -r d68efaaa2ff9 -r 312dba7e2116 sage/stats/hmm/chmm.pyx
    a b  
    5959        # Assign model identifier (the name) if specified
    6060        if name is not None:
    6161            name = str(name)
    62             self.m.name = <char*> safe_malloc(len(name))
     62            self.m.name = <char*> safe_malloc(len(name)+1)
    6363            strcpy(self.m.name, name)
    6464        else:
    6565            self.m.name = NULL
  • sage/stats/hmm/hmm.pyx

    diff -r d68efaaa2ff9 -r 312dba7e2116 sage/stats/hmm/hmm.pyx
    a b  
    190190        # Assign model identifier if specified
    191191        if name is not None:
    192192            name = str(name)
    193             self.m.name = <char*> safe_malloc(len(name))
     193            self.m.name = <char*> safe_malloc(len(name)+1)
    194194            strcpy(self.m.name, name)
    195195        else:
    196196            self.m.name = NULL