3 ms·
Since they're comparing against a literal string, which is guaranteed to be NULL terminated, what's wrong with that?
by icebraining 13y ago
Since they're comparing against a literal string, which is guaranteed to be NULL terminated, what's wrong with that?
- raverbashing 13y agoApparently it is safe http://stackoverflow.com/questions/448563/am-i-correct-that-strcmp-is-equivalent-and-safe-for-literals http://stackoverflow.com/questions/448563/am-i-correct-that-... However, some people may have the temptation of, when changing the code, replacing it with a non-literal string, or, in a rare case, there's a memory corruption affecting the literal string making it lose the null-termination.
- poolpOrg 13y agoso there's a bug if someone is tempted to modify it and break otherwise correct code ? i'd be tempted to say that we can apply the same logic to about 100% of code ever written.
- raverbashing 13y agoNot a bug, but some warning comment might be useful.