glDrawElements usage

Hi, all!
I’m trying to draw a square as a pair of triangles. I’m using glDrawElements, but the program crashes!
What did I do wrong?

GLshort vertex[] = 
{
        0,0,
        0,50,
        50,50,
        50,0
};

glEnableClientState(GL_VERTEX_ARRAY);    
glVertexPointer(2, GL_SHORT, 0, vertex);

GLubyte index[] = { 0,1,2, 0,2,3};
glDrawElements( GL_TRIANGLE_FAN, 6, GL_UNSIGNED_BYTE, index ); // Crash, but if I write glDrawArrays it works!

glDisableClientState(GL_VERTEX_ARRAY);

==========================================

Thank you!

Are you sure all other client arrays are disabled, and that there is no buffer object bound to GL_ELEMENT_ARRAY_BUFFER?

Also, with GL_TRIANGLE_FAN and 6 vertices, you actually get 4 triangles.

Thank you very much,the problem has been solved out. The code is absolutely normal; the reason was an incorrect gl library build.