Skip to content

fix: prevent nil pointer dereference in envoyGoFilterOnHttpData#19

Merged
johnlanni merged 1 commit intoenvoy-1.36from
fix-nil-pointer-in-onhttpdata-1.36
Jan 31, 2026
Merged

fix: prevent nil pointer dereference in envoyGoFilterOnHttpData#19
johnlanni merged 1 commit intoenvoy-1.36from
fix-nil-pointer-in-onhttpdata-1.36

Conversation

@johnlanni
Copy link
Copy Markdown

Description

Replace getState() with getOrCreateState() in envoyGoFilterOnHttpData to handle cases where OnHttpData is called before OnHttpHeader.

Problem

When envoyGoFilterOnHttpData is called before envoyGoFilterOnHttpHeader, the s.req pointer is not yet initialized, causing a nil pointer dereference panic:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x7fe25dce3faf]

Solution

  • Changed getState(s) to getOrCreateState(s) in line 239
  • getOrCreateState checks if the request exists and creates it if needed, preventing the nil pointer access
  • This matches the pattern already used in envoyGoFilterOnHttpHeader

Testing

  • Fixes the SIGSEGV panic reported in production logs

Replace getState() with getOrCreateState() to handle cases where
OnHttpData is called before OnHttpHeader, preventing SIGSEGV panic
when s.req is not yet initialized.

Fixes: panic: runtime error: invalid memory address or nil pointer dereference
@lingma-agents
Copy link
Copy Markdown

lingma-agents bot commented Jan 31, 2026

🔍 代码审查进行中

⏳ 正在审查

⏰️ 剩余时间:约需数分钟

🔄 分支流向: fix-nil-pointer-in-onhttpdata-1.36envoy-1.36

📦 提交: 审查当前PR从82e8bde179318a的提交。


📒 文件清单 (1 个文件)
📝 变更: 1 个文件

📝 变更文件:

  • contrib/golang/filters/http/source/go/pkg/http/shim.go

@johnlanni johnlanni merged commit d28d8db into envoy-1.36 Jan 31, 2026
2 of 3 checks passed
@lingma-agents
Copy link
Copy Markdown

lingma-agents bot commented Jan 31, 2026

CodeReview流程已终止

johnlanni added a commit that referenced this pull request Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant