Exception Thrown after using glTexImage2D

I am trying to call a function on my Model3D class (my created class for OBJ models) wherein I load the model’s texture but Visual Studio tells me there is an error–

Exception thrown at 0x00007FFC0E3CFD97 (ig11icd64.dll) in glfwsetup.exe: 0xC0000005: Access violation reading location 0x000001C7B701C000.

Here is the function in question:

void Model3D::loadTexture(int i) {
	std::string strTexPath = texturePath;

	unsigned char* tex_bytes =

	// Generate a reference
	glGenTextures(1, &texture);
	glActiveTexture(GL_TEXTURE0 + i);
	glBindTexture(GL_TEXTURE_2D, texture);

	if (tex_bytes) {
                // All rendered textures are .png files for now
		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, img_width, img_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, tex_bytes);
		GLenum err;
		while ((err = glGetError()) != GL_NO_ERROR)
			std::cout << "OpenGL Error " << err << std::endl;
	else {
		std::cout << "Failed to load image" << std::endl;



So far, what I’ve noticed is that the error is isolated into one Model3D variable. But given the application stops after the exception was thrown, I have no idea how to properly debug this without using glGetError().

// glfwsetup.cpp OR main.cpp
    // ...

    cSteve.loadTexture(0);        // This works
    cFire.loadTexture(1);           // This does NOT work, even with the previous function call commented out