Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#FFcccc
/* ... */
char buff[256];
if (getenv("EDITOR") !== NULL) {
  strcpy(buff, getenv("EDITOR"));
} else {
  /* No EDITOR environment variable! */
} else {
  strcpy(buff, getenv("EDITOR"));
}
/* ... */

Compliant Solution

...

Code Block
bgColor#ccccff
/* ... */
char *editor;
char *buff;

editor = getenv("EDITOR");
if (!editor) {
  /* No EDITOR environment variable! */
} else {
  size_t len = strlen(editor)+1;
  buff = (char *)malloc(len);
  if (!buff) {
    /* Handle malloc() Error */
  }
  memcpy(buff, editor, len);
}
/* ... */

...