Skip to content
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

Fixed StrGet with Length >= 256 (backport length_is_max_size from v2) #336

Open
wants to merge 1 commit into
base: v1.1
Choose a base branch
from

Conversation

DartVanya
Copy link

StrGet with lenght >= MAX_NUMBER_LENGTH (255) copy characters after null terminator (if lenght => StrLen(source_str)).
This brokes the result string (wrong lengh, cannot concat to it, etc).

Testbench:

test := "C:\Windows"

buffSize := 128
VarSetCapacity(buff, buffSize << !!A_IsUnicode, 0)
StrPut(test, &buff, buffSize)
out := StrGet(&buff, buffSize)
len := StrLen(out)
out .= "\"
MsgBox, % "len = " len "`n" out
; Result (as expected):
; len = 10
; C:\Windows\

buffSize := 256		;This happens if lenght param >= MAX_NUMBER_LENGTH (255)
VarSetCapacity(buff, buffSize << !!A_IsUnicode, 0)
StrPut(test, &buff, buffSize)
out := StrGet(&buff, buffSize)
len := StrLen(out)
out .= "\"
MsgBox, % "len = " len "`n" out
; Result (out string contains embedded null characters. Normal string behavior is broke):
; len = 256
; C:\Windows

It is fixed in v2. This backport fixes bug for v1. I tested code above and it started working correctly.

@Animan8000
Copy link
Contributor

This pull request won't be accepted, because v1.1 has already reached end of life and won't be maintained anymore. Lexikos is currently focusing on v2.0 and v2.1 (alpha), as of right now, and there is no good reason, to keep working on v1.1 anymore. Cheers.

@DartVanya
Copy link
Author

This pull request won't be accepted, because v1.1 has already reached end of life and won't be maintained anymore. Lexikos is currently focusing on v2.0 and v2.1 (alpha), as of right now, and there is no good reason, to keep working on v1.1 anymore. Cheers.

Oh, I didn't know, that 1.37.02 is last v1 version.

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.

2 participants