nibblebits / PeachOS

Simple kernel designed for a online course
GNU General Public License v2.0
135 stars 56 forks source link

Memory leak file.c fopen() #17

Open JaihsonK opened 1 year ago

JaihsonK commented 1 year ago

Hey Dan!

I found a memory leak in the fopen() function. In case of an error, we do not free root_path or descriptor_private_data. this would create a memory leak, especially if the error occurs on line 175 (PeachOS-master). My proposed solution is as follows:

out: // fopen shouldnt return negative values if (res < 0) { if(root_path) pathparser_free(root_path); if(descriptor_private_data) kfree(descriptor_private_data); res = 0; } return res;

nibblebits commented 1 year ago

Thanks for that much appreciated, I know youve made a couple issue reports don't worry I am not ignoring you, I am waiting because I plan to make a part 2 to the course, so just before I start I plan to make one big lecture fixing all of the problems

JaihsonK commented 1 year ago

OK no problem!

Cheers, Jaihson