string: sanitize nstrcmp return value on error
This commit is contained in:
parent
a1ac5d8c41
commit
66032c95f2
1 changed files with 10 additions and 2 deletions
|
@ -11,13 +11,21 @@
|
|||
|
||||
int nstrcmp(const string *s1, const string *s2, error *err)
|
||||
{
|
||||
/*
|
||||
* Return values are always undefined if an error was yeeted so it's not
|
||||
* strictly necessary to return a correct(ish) result here, but the
|
||||
* philosophy of libneo is to always behave in a way that is the least
|
||||
* harmful.
|
||||
*/
|
||||
if (s1 == nil) {
|
||||
yeet(err, EFAULT, "First string is nil");
|
||||
if (s2 == nil)
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
if (s2 == nil) {
|
||||
yeet(err, EFAULT, "Second string is nil");
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ret;
|
||||
|
|
Loading…
Reference in a new issue