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

Bug in MemoryUtil.memCopy methods #414

Closed
vearp opened this issue Sep 10, 2018 · 1 comment
Closed

Bug in MemoryUtil.memCopy methods #414

vearp opened this issue Sep 10, 2018 · 1 comment

Comments

@vearp
Copy link

vearp commented Sep 10, 2018

Environment

  • LWJGL version: 3.2.0
  • LWJGL build #: build 12
  • Java version: 1.8.0_171
  • Platform: Windows
  • Module: core

Description

There is a bug in MemoryUtil.memCopy methods. The methods checks if the the destination buffer has enough bytes to hold the remaining bytes from source. But the check is checking the opposite, it checks if the source has enough bytes to hold the dest buffer. If the dest buffer is the bigger one, this leads to a thrown exception.

   public static void memCopy(ByteBuffer src, ByteBuffer dst) {
         if (CHECKS) {
             check(src, dst.remaining());
         }
         memCopy(memAddress(src), memAddress(dst), src.remaining());
    }

should be:

     public static void memCopy(ByteBuffer src, ByteBuffer dst) {
         if (CHECKS) {
            check(dst, src.remaining());
         }
         memCopy(memAddress(src), memAddress(dst), src.remaining());
    }

This goes for all the variants.

blw043 added a commit to blw043/lwjgl3 that referenced this issue Sep 23, 2018
@blw043 blw043 mentioned this issue Sep 23, 2018
Spasi added a commit to blw043/lwjgl3 that referenced this issue Sep 29, 2018
@Spasi Spasi closed this as completed in 8c52194 Sep 29, 2018
@Spasi
Copy link
Member

Spasi commented Sep 29, 2018

@vearp Thanks!

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

No branches or pull requests

2 participants