...
Code Block | ||
---|---|---|
| ||
/* ... */ 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 | ||
---|---|---|
| ||
/* ... */ 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); } /* ... */ |
...