Skip to content

Commit

Permalink
Do not put binary illustration data into a string.
Browse files Browse the repository at this point in the history
Java String must contains utf8 content.
Illusration data which is PNG is definitively not a utf8 string.

Fix #73
  • Loading branch information
mgautierfr committed Nov 9, 2023
1 parent f9dc43e commit cce174c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/src/main/cpp/libkiwix/illustration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@ METHOD0(jstring, url) {
return TO_JNI(THIS->url);
} CATCH_EXCEPTION(nullptr)

GETTER(jstring, getData)
METHOD0(jbyteArray, getData) {
auto data = THIS->getData();
return cArray2jni(data->c_str(), data->size(), env)
} CATCH_EXCEPTION(nullptr)
2 changes: 1 addition & 1 deletion lib/src/main/java/org/kiwix/libkiwix/Illustration.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class Illustration
public native String mimeType();
public native String url();

public native String getData();
public native byte[] getData();
@Override
protected void finalize() { dispose(); }

Expand Down

0 comments on commit cce174c

Please sign in to comment.