qingoba commented on PR #1565:
URL: https://github.com/apache/incubator-fury/pull/1565#issuecomment-2078748803

   There is another question.
   If input string is empty, endcode bytes is also empty:
   ```java
   public MetaString encode(String input, Encoding encoding) {
     Preconditions.checkArgument(
         input.length() < Short.MAX_VALUE, "Long meta string than 32767 is not 
allowed");
     if (input.isEmpty()) {
       return new MetaString(input, Encoding.UTF_8, specialChar1, specialChar2, 
new byte[0]);
     }
   }
   ```
   However, decode procedure doesn't check empty. It will access `bytes[0]` 
directly:
   ```java
   private String decodeLowerSpecial(byte[] data) {
     StringBuilder decoded = new StringBuilder();
     int totalBits = data.length * 8; // Total number of bits in the data
     boolean stripLastChar = (data[0] & 0x80) != 0; // Check the first bit of 
the first byte
   }
   ```
   So decode procedure should check empty.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to