Skip to content

Fix double free #1366

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

Merged
merged 1 commit into from
Nov 13, 2019
Merged

Fix double free #1366

merged 1 commit into from
Nov 13, 2019

Conversation

hannesweisbach
Copy link
Contributor

_fileName and _values have to be re-set to NULL, otherwise a double-free might occur.

First destroy() is called when the eeprom filesize does not match, the second destroy() is called from the dtor of SoftEeprom on exit:

Nov 11 17:00:01 INFO Starting gateway...
Nov 11 17:00:01 INFO Protocol version - 2.3.2-beta
Nov 11 17:00:01 ERROR EEPROM file /etc/mysensors.eeprom is not the correct size of 1024. Please remove the file and a new one will be created.
double free or corruption (!prev)

Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51 ../sysdeps/unix/sysv/linux/raise.c: Datei oder Verzeichnis nicht gefunden.
(gdb) bt
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1 0x76c6ed2c in __GI_abort () at abort.c:79
#2 0x76ca8cec in __libc_message (action=action@entry=do_abort, fmt=) at ../sysdeps/posix/libc_fatal.c:181
#3 0x76caf550 in malloc_printerr (str=) at malloc.c:5350
#4 0x76cb15ac in _int_free (av=0x76d8a7c4 <main_arena>, p=0x485d8, have_lock=) at malloc.c:4281
#5 0x0001931c in SoftEeprom::destroy (this=0x406f4 ) at hal/architecture/Linux/drivers/core/SoftEeprom.cpp:100
#6 SoftEeprom::~SoftEeprom (this=0x406f4 , __in_chrg=) at hal/architecture/Linux/drivers/core/SoftEeprom.cpp:46
#7 0x76c70424 in __run_exit_handlers (status=status@entry=1, listp=, run_list_atexit=run_list_atexit@entry=true, run_dtors=run_dtors@entry=true) at exit.c:108
#8 0x76c7054c in __GI_exit (status=status@entry=1) at exit.c:139
#9 0x00026840 in hwInit () at ./hal/architecture/Linux/MyHwLinuxGeneric.cpp:38
#10 _begin () at ./core/MySensorsCore.cpp:116
#11 0x00012f08 in main (argc=1, argv=0xc) at ./hal/architecture/Linux/MyMainLinuxGeneric.cpp:447

I would suggest changing the _fileName to a std::string and _values to a std::vector<uint8_t>. I would make the change, if you're ok with it?

@tekka007
Copy link
Contributor

@hannesweisbach Thank you for submitting this PR. Would you mind signing the CLA?

@tekka007 tekka007 added the RPi label Nov 11, 2019
_fileName and _values have to be re-set to NULL, otherwise a
double-free might occur.
@tekka007
Copy link
Contributor

I would suggest changing the _fileName to a std::string and _values to a std::vector<uint8_t>. I would make the change, if you're ok with it?

Sure!

@hannesweisbach
Copy link
Contributor Author

Do you want to merge this PR in the mean time? I guess I'll have time to implement it sometime next week.

@tekka007
Copy link
Contributor

ok, thanks!

@tekka007 tekka007 merged commit 60d62ca into mysensors:development Nov 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants