Pelles C > Announcements

Release Candidate for version 11.00 is now available

(1/12) > >>

Pelle:
http://www.smorgasbordet.com/pellesc/download.htm

John Z:
Wow amazing! Thank you Pelle.  Congratulations too.

John Z

Marco:
Great news! Thanks Pelle. I'm going to test it.

Grincheux:
Thank You for this great jo Mr Pelle.

Marco:
Well, there are several more warnings during the compilation process, and some of them helped me to trace down a couple of tricky bugs. So, thanks Pelle again!

Regarding to the warnings, when I free an allocated buffer, and the same buffer is also freed elsewhere, the compiler shows the following:

--- Code: ---void foo(void)
{
  char *buffer = malloc(32);
  if (buffer == NULL) return;
  buffer[0] = '\0';

  DWORD dwRet = GetLastError();           <-- Just an example. This is not important.
  if (dwRet)
  {
        free(buffer);
        return;
  }

  free(buffer);                           <-- warning #2116: Local 'buffer' is used without being initialized (or using a dangling value).
}

--- End code ---

To 'fix' the warning, I have to modify the code as following:

--- Code: ---void foo(void)
{

  char *buffer = malloc(32);
  if (buffer == NULL) return;
  buffer[0] = '\0';

  DWORD dwRet = GetLastError();
  if (dwRet)
  {
        free(buffer); buffer = NULL;      <-- 'fix'
        return;
  }

  free(buffer);                           <-- no more warning
}

--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version