#14 Wrong order of sanity checks

closed-fixed
nobody
None
5
2005-06-27
2003-03-14
Anonymous
No

While browsing through the library source code I
noticed at several places in obex.c:

if (self->object) {
DEBUG(1, "We are busy.\n");
return -EBUSY;
}
obex_return_val_if_fail(self != NULL, -1);

which will lead to a fabulous crash if self == NULL :-)
The correct order would be:

obex_return_val_if_fail(self != NULL, -1);
if (self->object) {
DEBUG(1, "We are busy.\n");
return -EBUSY;
}

or maybe even easier

obex_return_val_if_fail(self != NULL, -1);
obex_return_val_if_fail(!self->object, -EBUSY);

All places where obex_return_val_if_fail() is used
should be checked...

mailto:Stefan.Becker@nokia.com

Discussion

  • Christian W. Zuckschwerdt

    • status: open --> closed
     
  • Christian W. Zuckschwerdt

    • status: closed --> closed-fixed
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks