Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpp console example app leaks memory #10

Open
oschonrock opened this issue Sep 6, 2021 · 0 comments
Open

cpp console example app leaks memory #10

oschonrock opened this issue Sep 6, 2021 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@oschonrock
Copy link

if you run the example app code with address sanatizer it shows that it leaks memory.

==451983==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 256 byte(s) in 1 object(s) allocated from:
    #0 0x7fdb7d4f8f27 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:99
    #1 0x7fdb7d3bbdd0 in sql::mariadb::SelectResultSet::create(sql::mariadb::Results*, sql::mariadb::Protocol*, sql::mariadb::capi::st_mysql*, bool) /home/buildbot/src/src/SelectResultSet.cpp:79

The issue is the result sets, eg this:

        sql::ResultSet *res = stmnt->executeQuery("select * from tasks");

needs to be wrapped in a unique_ptr to ensure it gets cleaned up at end of scope:

    std::unique_ptr<sql::ResultSet> res(stmnt->executeQuery("select * from tasks"));

This applies to every result_set in the example app. ie every time stmnt->execute*() is called

@rhedgpeth rhedgpeth self-assigned this Sep 21, 2021
@rhedgpeth rhedgpeth added the bug Something isn't working label Sep 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants