Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

free(): invalid pointer: #45

Open
ynsbalci opened this issue Aug 17, 2018 · 3 comments
Open

free(): invalid pointer: #45

ynsbalci opened this issue Aug 17, 2018 · 3 comments

Comments

@ynsbalci
Copy link

hi!
I've compiled the project in linux mint for codeblocks, but I get a pointer error. In "stb_image.c" the free() funcions is giving an error. what can i do?
thanks have a good day.

@shivamprasad99
Copy link

I am also getting same error:
free(): invalid pointer
Aborted (core dumped)
on building from the terminal in Ubuntu 18.04
What should I do?

@Phobos03
Copy link

Phobos03 commented May 3, 2022

Hello, I know that this is old repo, but I also have the same issue like shivamprasad99 with free(): invalid pointer
Aborted (core dumped). Maybe someone resolve this issue already?

@gedeschaines
Copy link

Fixes to prevent Policy warnings from syntax errors in CMake code files.

  1. File: ./cmake/FindGLEW.cmake
    insert: SET(PROGRAMFILESX86 "PROGRAMFILES(X86)")
    before: SET( GLEW_SEARCH_PATHS
    and
    change: "$ENV{PROGRAMFILES(X86)}/GLEW"   # WINDOWS
        to: "$ENV{${PROGRAMFILESX86}}/GLEW"     # WINDOWS
  1. File: ./cmake/FindSDL2.cmake
    insert: SET(PROGRAMFILESX86 "PROGRAMFILES(X86)")
    before: SET( SDL2_SEARCH_PATHS
    and
    change: "$ENV{PROGRAMFILES(X86)}/SDL2"     # WINDOWS
        to: "$ENV{${PROGRAMFILESX86}}/SDL2"   # WINDOWS
  1. File: ./cmake/FindASSIMP.cmake
    insert: SET(PROGRAMFILESX86 "PROGRAMFILES(X86)")
    before: SET( ASSIMP_SEARCH_PATHS
    and
    change: "$ENV{PROGRAMFILES(X86)}/ASSIMP"	# WINDOWS
        to: "$ENV{${PROGRAMFILESX86}}/ASSIMP"	# WINDOWS

Fixes to prevent program execution abort on free(): invalid pointer.

  1. File: ./src/rendering/texture.h, line 60
    from: void operator=(Texture texture);
      to: Texture& operator=(Texture other) noexcept;
  1. File: ./src/rendering/texture.cpp, lines 207-213

    replace:

    void Texture::operator=(Texture texture)
    {
        char* temp[sizeof(Texture)/sizeof(char)];
        memcpy(temp, this, sizeof(Texture));
	memcpy(this, &texture, sizeof(Texture));
        memcpy(&texture, temp, sizeof(Texture));
    }
  with:
    Texture& Texture::operator=(Texture other) noexcept
    {
        //Implemented using move assignment.
    
        //Guard self assignment
        if (this == &other)
            return *this;
    
        if(m_textureData && m_textureData->RemoveReference())
	{
            if(m_fileName.length() > 0)
                s_resourceMap.erase(m_fileName);
	    
	        delete m_textureData;
	}
	m_fileName = other.m_fileName;
        m_textureData = other.m_textureData;
        m_textureData->AddReference();
        return *this;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants