Martinsos / edlib

Lightweight, super fast C/C++ (& Python) library for sequence alignment using edit (Levenshtein) distance.
http://martinsos.github.io/edlib
MIT License
492 stars 162 forks source link

memory leak identified in myersCalcEditDistanceSemiGlobal #193

Open GDCCP opened 2 years ago

GDCCP commented 2 years ago

Description

static int myersCalcEditDistanceSemiGlobal(
        const Word* const Peq, const int W, const int maxNumBlocks,
        const int queryLength,
        const unsigned char* const target, const int targetLength,
        int k, const EdlibAlignMode mode,
        int* const bestScore_, int** const positions_, int* const numPositions_) {
    *positions_ = NULL;
    *numPositions_ = 0;

The statement *positinos_ = NULL; can lead to memory leak as *positions_ before the assignment is not released.

This is discovered during code inspection when working on https://github.com/Martinsos/edlib/issues/84