This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

strtok behaviour when uninitialized


All,

When using strtok for the first time without initializing
it throws a segfault. Following code can reproduce the error

int main() {
    char* str = strtok(NULL, " ");
    return 1;
}

I am aware that this is not the correct way of using strtok. First
call should always pass a non NULL string. Before glibc 2.23 strtok
used to return a NULL for the above code. Would it make sense to
add a NULL check and not let strtok throw a segfault?

-Salil


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]