GithubHelp home page GithubHelp logo

hash_map_free bug about c-utils HOT 3 CLOSED

gotomain avatar gotomain commented on July 19, 2024
hash_map_free bug

from c-utils.

Comments (3)

sidcha avatar sidcha commented on July 19, 2024

@tuchun, yes that is a bug. Thanks for reporting it.

Do you want to send a pull request for this change? Since you found and fixed it, you might as well commit it :)

from c-utils.

codemanchris avatar codemanchris commented on July 19, 2024

@tuchun, yes that is a bug. Thanks for reporting it.

Do you want to send a pull request for this change? Since you found and fixed it, you might as well commit it :)

No ^_^, just fix it, there is also a problem with the test , free is called after delete, so cannot be tested correctly.

TEST_DEF(hashmap)
{
	char *buf;
	const char * const *words;
	size_t size, count;
	hash_map_t map;
	TEST_MOD_INIT();

	TEST_MOD_READ_FILE("words_alpha.txt", &buf, &size);
	count = test_build_word_list(buf, &words);

	hash_map_init(&map);

	TEST_MOD_EXEC( test_dict_insert(&map, words, count) );
	TEST_MOD_EXEC( test_dict_iterator(&map, words, count) );
        //test_dict_delete has freed the map
	TEST_MOD_EXEC( test_dict_delete(&map, words, count) );
	TEST_MOD_EXEC( map.count );

        //so hash_map_free not covered by tests
	hash_map_free(&map, free_test_hashmap_value);

	safe_free(buf);
	safe_free((void *)words);
	TEST_MOD_REPORT();
}

from c-utils.

sidcha avatar sidcha commented on July 19, 2024

One bug covering for another, very typical. 🤯

Thanks, fixed both.

from c-utils.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.