[PR #1413] java: add explicit null check in BrotliInputStream.read #2022

Open
opened 2026-01-29 20:56:59 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/google/brotli/pull/1413
Author: @leofernandesmo
Created: 1/21/2026
Status: 🔄 Open

Base: masterHead: fix-java-brotliinputstream-null-buffer


📝 Commits (1)

  • e7f00f6 java: add explicit null check in BrotliInputStream.read

📊 Changes

1 file changed (+3 additions, -0 deletions)

View changed files

📝 java/org/brotli/dec/BrotliInputStream.java (+3 -0)

📄 Description

  • Problem: BrotliInputStream.read(byte[], int, int) currently dereferences destBuffer.length during bounds checking, so passing a null buffer triggers a NullPointerException from the dereference rather than an explicit parameter check.

  • Why change: InputStream.read(byte[], int, int) specifies NullPointerException when the buffer argument is null, so this change preserves the expected exception type while making the failure mode explicit and easier to diagnose.

Repro:

InputStream in = InputStream.nullInputStream();
BrotliInputStream br = new BrotliInputStream(in);
br.read((byte[]) null, 0, 1);

  • Fix: add early destBuffer == null check and throw NullPointerException("destBuffer is null").
  • CLA note: “I understand this repo requires the Google CLA and will complete it if/when requested.”

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/google/brotli/pull/1413 **Author:** [@leofernandesmo](https://github.com/leofernandesmo) **Created:** 1/21/2026 **Status:** 🔄 Open **Base:** `master` ← **Head:** `fix-java-brotliinputstream-null-buffer` --- ### 📝 Commits (1) - [`e7f00f6`](https://github.com/google/brotli/commit/e7f00f63486c7aee45b5770a83bfd9e37f794b65) java: add explicit null check in BrotliInputStream.read ### 📊 Changes **1 file changed** (+3 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `java/org/brotli/dec/BrotliInputStream.java` (+3 -0) </details> ### 📄 Description - **Problem**: BrotliInputStream.read(byte[], int, int) currently dereferences destBuffer.length during bounds checking, so passing a null buffer triggers a NullPointerException from the dereference rather than an explicit parameter check. - **Why change**: InputStream.read(byte[], int, int) specifies NullPointerException when the buffer argument is null, so this change preserves the expected exception type while making the failure mode explicit and easier to diagnose. Repro: ``` InputStream in = InputStream.nullInputStream(); BrotliInputStream br = new BrotliInputStream(in); br.read((byte[]) null, 0, 1); ``` - **Fix**: add early destBuffer == null check and throw NullPointerException("destBuffer is null"). - **CLA note**: “I understand this repo requires the Google CLA and will complete it if/when requested.” --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 20:56:59 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/brotli#2022