Skip to content

Commit

Permalink
new fix for NPE #12
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenArzt committed Sep 27, 2022
1 parent 97656d7 commit 1ef9010
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/pxb/android/StringItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ public void prepare() throws IOException {
item.dataOffset = offset;
map.put(stringData, offset);
if (useUTF8) {
int length = stringData.length();
byte[] data = stringData.getBytes("UTF-8");
int length = stringData == null ? 0 : stringData.length();
byte[] data = stringData == null ? new byte[0] : stringData.getBytes("UTF-8");
int u8lenght = data.length;

if (length > 0x7F) {
Expand All @@ -125,8 +125,8 @@ public void prepare() throws IOException {
baos.write(0);
offset += 3 + u8lenght;
} else {
int length = stringData.length();
byte[] data = stringData.getBytes("UTF-16LE");
int length = stringData == null ? 0 :stringData.length();
byte[] data = stringData == null ? new byte[0] : stringData.getBytes("UTF-16LE");
if (length > 0x7FFF) {
int x = (length >> 16) | 0x8000;
baos.write(x);
Expand Down

0 comments on commit 1ef9010

Please sign in to comment.