-
Notifications
You must be signed in to change notification settings - Fork 0
Potential fix for code scanning alert no. 5: Size computation for allocation may overflow #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,10 @@ func CamelToSnake(s string) string { | |
| } | ||
|
|
||
| func ChangeJsonKeys(input []byte, f func(s string) string) []byte { | ||
|
|
||
| // Guard against allocation overflow: reject very large input | ||
| if len(input) > 64*1024*1024 { // 64MB | ||
| return input // Or nil, or error handling as you prefer | ||
| } | ||
|
Comment on lines
+29
to
+32
|
||
| buf := bytes.NewBuffer(make([]byte, 0, len(input)+8)) | ||
| isMap := false | ||
| nextTokenIsKey := false | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The inline comment "// Or nil, or error handling as you prefer" should be removed. This comment appears to be placeholder text from development and doesn't add value to production code. Comments should explain "why" not list alternative implementations.