#3925 closed Bug (Fixed)
With..EndWith should error out when associated with a DllStruct
| Reported by: | jchd18 | Owned by: | J-Paul Mesnage |
|---|---|---|---|
| Milestone: | 3.3.17.0 | Component: | Aut2Exe |
| Version: | 3.3.16.1 | Severity: | None |
| Keywords: | Cc: |
Description (last modified by )
With $X is specified to work only if $X is an object.
Instead it doesn't errour out when $X is a DllStruct.
Uncomment any other datatype below to produce a runtime error.
Local $m[]
Local $b[3]
Local $a = [ _
DllStructCreate('wchar string[1024]'), _
_ ; $m, _
_ ; $b, _
_ ; 123, _
_ ; "abc", _
_ ; Binary(123), _
_ ; Ptr(123456), _
_ ; True, _
_ ; Null _
ObjCreate("shell.application") _
]
For $v In $a
ConsoleWrite(VarGetType($v) & @TAB)
With $v
ConsoleWrite("passed" & @LF)
EndWith
Next
Maybe these checks should also be integrated in Au3Check if at all reasonably possible.
Origin thread: https://www.autoitscript.com/forum/topic/209063-beware-of-abusing-undocumented-withendwith-syntax-on-dllstructs/
Attachments (0)
Change History (8)
comment:1 by , 3 years ago
| Description: | modified (diff) |
|---|
comment:2 by , 3 years ago
| Summary: | Witn..EndWith should error out when associated with a DllStruct → With..EndWith should error out when associated with a DllStruct |
|---|
comment:3 by , 3 years ago
comment:5 by , 3 years ago
Replying to anonymous:
doesn't address the memory leak though
Forgot to paste the code from the original thread:
HotKeySet('{esc}',quit)
GUICreate("")
GUISetState()
Local $text
While 1
$text = state()
Sleep(10) ; don't remove this, or your RAM will blow up instantly
WEnd
Func state()
Local Static $struct = DllStructCreate('wchar string[1024]')
With $struct
Return .string
EndWith
EndFunc
Func quit()
exit
EndFunc
comment:6 by , 3 years ago
| Milestone: | → 3.3.17.0 |
|---|---|
| Owner: | set to |
| Resolution: | → Fixed |
| Status: | new → closed |
Fixed by revision [12890] in version: 3.3.17.0
follow-up: 8 comment:7 by , 3 years ago
Does that fix the memory leak or does it just prevent returning struct members from within a With?
comment:8 by , 3 years ago
Replying to anonymous:
Does that fix the memory leak or does it just prevent returning struct members from within a With?
I can understand that is a new ticket so I leave this one close
Just open a new ticket for the leak memory

For me only the doc can be improved as $v.string is a valid expression
Local $m[] Local $b[3] Local $a = [ _ DllStructCreate('wchar string[1024]'), _ _ ; $m, _ _ ; $b, _ _ ; 123, _ _ ; "abc", _ _ ; Binary(123), _ _ ; Ptr(123456), _ _ ; True, _ _ ; Null, _ ObjCreate("shell.application") _ ] For $v In $a ConsoleWrite(VarGetType($v) & @TAB) With $v ConsoleWrite("passed" & @LF) If IsDllStruct($v) Then $v.string = "x" ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $v.string = ' & $v.string & @CRLF & '>Error code: ' & @error & ' Extended code: ' & @extended & ' (0x' & Hex(@extended) & ')' & @CRLF) ;### Debug Console EndIf EndWith Next