Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: comply with MEM02-A by not typecasting malloc.

...

Code Block
bgColor#FFCCCC
int main(int argc, char *argv[]) {
  char *buff;

  buff = (char *)malloc(BUFSIZE);
  if (!buff) {
     /* handle error condition */
  }
  ...
  free(buff);
  ...
  strncpy(buff, argv[1], BUFSIZE-1);
}

...

Code Block
bgColor#ccccff
int main(int argc, char *argv[]) {
  char *buff;

  buff = (char *) malloc(BUFSIZE);
  if (!buff) {
     /* handle error condition */
  }
  ...
  strncpy(buff, argv[1], BUFSIZE-1);
  ...
  free(buff);

}

...