News for hackers. Stuff that matters.
Re:This is the exploit equivalent of that guy who played the... by ianbishop on Monday July 06, 2009 @08:33PM (#690710)
From my understanding, his problem was that the malloc wrapper being used not only checked but also returned -1 if it was null (I assume some other arbitrary number otherwise) which would add extra computation time.

Out of curiosity, I have always used assert to do malloc null checks. I realize it is just a macro which gives a conditional to exit but is at all hindering in terms of performance?

eg:

  void *Malloc(size_t size) {

    void *r = malloc(size);
    assert(r != null);

    return r;
  }
Re:This is the exploit equivalent of that guy who played the... by dbenamy on Monday July 06, 2009 @08:54PM (#690725)
That's probably the same as the non-assert check EXCEPT that release builds might disable assertions and then you're in trouble.
Re:This is the exploit equivalent of that guy who played the... by basugasubaku on Tuesday July 07, 2009 @12:40AM (#690935)
Right. Plus as a matter of style, assertions are traditionally distinguished from error handling. Assertions are used to catch programmer errors; error handling is for when something happens that is nevertheless within the contract of the library (malloc can return NULL, fopen can return NULL, etc).
Re:This is the exploit equivalent of that guy who played the... by ori_b on Tuesday July 07, 2009 @11:42AM (#691665)
the problem is that assert is defined so that if NDEBUG is defined, it's a no-op.

I'd use an explicit check and an abort() call.