I try to resolve the circuit satisfiability problem reading the circuit from file (in the form presented in text visualizer-somehow dynamic). If my circuit is small my resolver work smooth (small means like <16-18 wires). If i get to 25-30 wires so 2^25-30 possibilities i encountered a problem with a violation of access. I tried to free memory every time i can. I tried to create a new pointer of my expression every time, but the access violation always occur.

^ How is this possible ?
int evalBoolExprForBinaryVector(char *expr, int n, int binaryVector[]){
    // create boolean expression from logical expression
    char* expression = (char*) malloc(sizeof(char) * strlen(expr) + 1);
    strcpy(expression, expr);
    for(int binaryVectorCounter=0; binaryVectorCounter<n; binaryVectorCounter++){
        char* currentSearchedIdentifier = (char*) malloc(sizeof(char) * 10);
        char* index =(char*) malloc(sizeof(char) * 10);
        char* valueOfIndex = (char*) malloc(sizeof(char)*2);
        strcpy(currentSearchedIdentifier,"v[");
        sprintf(index, "%d", binaryVectorCounter);
        strcat(currentSearchedIdentifier, index);
        strcat(currentSearchedIdentifier, "]");
        sprintf(valueOfIndex, "%d", binaryVector[binaryVectorCounter]);
        expression = str_replace(expression,currentSearchedIdentifier,valueOfIndex);
        free(currentSearchedIdentifier);
        free(index);
        free(valueOfIndex);
    }
    // here my expression will be something like 
    // ( 0 | 1 ) & (!0 | !1) & ...
    // evaluate this
    return evalBoolExpr(expression);
};
Here is my code for better understanding.
The program breaks with this exception in strlen.asm at:
main_loop:
        mov     eax,dword ptr [ecx]     ; read 4 bytes
Thanks in advance for any thoughts.
