0

How to avoid memory leacks in this example? I am new in Botan...

I am using :

-Cygwin

-Cmake

-botan 1.8 version

#include <iostream>
using namespace std;

#include<botan/init.h>
#include<botan/md4.h>


int main(int argc, char ** argv) {
    try {
        Botan::LibraryInitializer init;
        //  Response res;
        Botan::MD4 md4;
        cout << "name: " << md4.name() << endl;


        md4.clear();



        init.deinitialize();

    } catch (exception &e) {

        cerr << e.what() << endl;
    }

    return 0;

}

Output from my compiler :

name: MD4
Segmentation fault (core dumped)
Szymon Madera
  • 87
  • 1
  • 6
  • 3
    Now is a perfect time to learn how to use a debugger. Build a version of your program with debug information, then run your program in a debugger. The debugger will stop at the location of the crash, and let you examine and walk up the function call stack. If the crash is not in your code, then go `up` the call-stack until you get to your code. If you can't figure it out by yourself with the help of the debugger, then at least edit your question to show where in your source the crash happens. – Some programmer dude Sep 24 '14 at 18:25
  • 1
    I haven't used botan and have no idea what I am saying, but I find it weird, that you have to call "deinitialize" when done, but there is no corresponding "init" call. If it's RAII, then it should automatically deinit when init goes out of scope, no? – thang Sep 24 '14 at 18:30

0 Answers0