flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From NicoK <...@git.apache.org>
Subject [GitHub] flink pull request #4593: [FLINK-7516][memory] do not allow copies into a re...
Date Wed, 01 Nov 2017 09:04:07 GMT
Github user NicoK commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4593#discussion_r148209947
  
    --- Diff: flink-core/src/main/java/org/apache/flink/core/memory/HybridMemorySegment.java
---
    @@ -306,6 +307,9 @@ public final void get(int offset, ByteBuffer target, int numBytes)
{
     		if ((offset | numBytes | (offset + numBytes)) < 0) {
     			throw new IndexOutOfBoundsException();
     		}
    +		if (target.isReadOnly()) {
    --- End diff --
    
    you are right - the non-direct buffers path is based on `ByteBuffer#array()` which will
throw a `ReadOnlyBufferException` for read-only buffers, so it really is enough in the direct
buffers code path where the `UNSAFE.copyMemory` is not checking the source pointer (how should
it?!)


---

Mime
View raw message