On Mon, Sep 3, 2012 at 5:50 PM, Jaap Keuter
<jaap.keuter@xxxxxxxxx> wrote:
Anyone knows what strstr() does with a NULL for a haystack? As far as I can tell it's unspecified.
I think you're right. "Undefined/unspecified behavior" usually means a segfault from my experience. This is true for strstr() in OSX ML.
strstr() apparently does not null-check its parameters in the latest versions of Linux [1], OSX/Darwin (and probably other Un*x) [2], and Windows [3]. I couldn't find the Windows source for
strstr(), but MSDN indicates:
strstr and wcsstr do not validate their parameters.
Interestingly, Windows does have an error handler in _mbsstr() for invalid parameters.