‫Hello, everybody.
‫We're just going to fix a quick memory leak if you look on fat 16 dot C lines, six, three, three,
‫you'll see we return an error, but we do not free the descriptive memory here.
‫This is obviously a memory leak and it needs to be resolved.
‫So we're going to resolve it.
‫So just under six, three, seven here, we're going to create an error out label and then we're just
‫going to say if the descriptor exists, Caffery descriptor and then we're just going to return error
‫error code and we're going to create that now.
‫So just appear we need to remove the descriptor here to the top the function.
‫OK, and we also can have an area code here which will just equal it to zero.
‫OK, and now here we're going to change these.
‫So what now happens is we say.
‫Error code equals minus nomen.
‫And then we're just going to go to Erra out.
‫And down here, we're just going to do the same minus zero go to out.
‫Now, I know that's a bit of a pain, guys handling memory in C can be more tedious than other languages.
‫This is one solution.
‫There are many ways to have done this.
‫This solution's OK.
‫It's generally acceptable to use go to if you have a reason to use it.
‫I believe memory management is a valid reason to use Agota as long as you don't abuse it.
‫There's other ways we could have written this as well.
‫So, yeah, you'll notice on Sexta too.
‫We also haven't changed that.
‫So we're going to go areaCode equals minus E Read-Only.
‫OK, and we're just going to go to Aroud again, so we had to move the descriptor at the top of this
‫function because otherwise it's not going to be on the stack.
‫OK, when we jump down to here, there's not a guarantee it will be on the stack if we put it all the
‫way at the top here.
‫Guarantees that, OK, for example, if we kept it where it was, this this go to here on six to three
‫wouldn't be able to access that memory correctly because it wouldn't be initialized yet.
‫OK, so that's why it's important to put it at the top.
‫That should now work.
‫OK, so if we just go to the command and we're going to go make clean bill that S.H..
‫So we can see that compilers, we're now going to KDDI and we're just going to run it, check everything
‫still works.
‫Now we can see we can see the program so still runs, so I can safely assume that our open works fine
‫because if it didn't, we wouldn't have been had to open the programs.
‫Right.
‫So unfortunately, encountering bugs in kernel development is extremely common.
‫And even I can make mistakes, but I will always correct them when I find them.
‫So this is the correction, guys.
‫Just do that or take a look at the source code attached to this lecture.
‫And thanks so much for watching.