Skip to content

Commit

Permalink
Merge pull request #24 from valeriyvan/leak
Browse files Browse the repository at this point in the history
Fixes possible memory leak
  • Loading branch information
craigsapp authored Dec 2, 2019
2 parents 3b56ab4 + 38c8c47 commit d877dc7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/humlib.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// Programmer: Craig Stuart Sapp <[email protected]>
// Creation Date: Sat Aug 8 12:24:49 PDT 2015
// Last Modified: Tue Nov 26 11:43:33 CET 2019
// Last Modified: Mon Dec 2 18:38:55 CET 2019
// Filename: humlib.h
// URL: https://github.com/craigsapp/humlib/blob/master/include/humlib.h
// Syntax: C++11
Expand Down
9 changes: 7 additions & 2 deletions src/GridSlice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,13 @@ void GridSlice::transferTokens(HumdrumFile& outfile, bool recip) {
token = new HumdrumToken("55");
empty = "!z";
}
if ((token != NULL) && hasSpines()) {
line->appendToken(token);
if (token != NULL) {
if (hasSpines()) {
line->appendToken(token);
} else {
delete token;
token = NULL;
}
}
}

Expand Down
11 changes: 8 additions & 3 deletions src/humlib.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// Programmer: Craig Stuart Sapp <[email protected]>
// Creation Date: Sat Aug 8 12:24:49 PDT 2015
// Last Modified: Tue Nov 26 11:43:33 CET 2019
// Last Modified: Mon Dec 2 18:38:55 CET 2019
// Filename: /include/humlib.cpp
// URL: https://github.com/craigsapp/humlib/blob/master/src/humlib.cpp
// Syntax: C++11
Expand Down Expand Up @@ -5766,8 +5766,13 @@ void GridSlice::transferTokens(HumdrumFile& outfile, bool recip) {
token = new HumdrumToken("55");
empty = "!z";
}
if ((token != NULL) && hasSpines()) {
line->appendToken(token);
if (token != NULL) {
if (hasSpines()) {
line->appendToken(token);
} else {
delete token;
token = NULL;
}
}
}

Expand Down

0 comments on commit d877dc7

Please sign in to comment.