Permalink
Browse files

fix memleak

  • Loading branch information...
1 parent c4df4dd commit 7d972770099fbde2e52c7bc1f29fe4ba4c1f048a @tebeka committed Apr 5, 2013
Showing with 8 additions and 2 deletions.
  1. +3 −0 ChangeLog
  2. +5 −2 snowball.go
View
@@ -1,3 +1,6 @@
+2013-04-05 version 0.1.3
+ * Fix possible memory leak
+
2012-12-06 version 0.1.2
* Free memory
View
@@ -17,7 +17,7 @@ import (
import "C"
const (
- Version = "0.1.2"
+ Version = "0.1.3"
)
// Stemmer structure
@@ -36,9 +36,12 @@ func free(stmr *Stemmer) {
// New creates a new stemmer for lang
func New(lang string) (*Stemmer, error) {
+ clang := C.CString(lang)
+ defer C.free(unsafe.Pointer(clang))
+
stmr := &Stemmer{
lang,
- C.sb_stemmer_new(C.CString(lang), nil),
+ C.sb_stemmer_new(clang, nil),
}
if stmr.stmr == nil {

0 comments on commit 7d97277

Please sign in to comment.