Modify

Opened 16 months ago

Closed 16 months ago

Last modified 16 months ago

#3925 closed Bug (Fixed)

With..EndWith should error out when associated with a DllStruct

Reported by: jchd18 Owned by: Jpm
Milestone: 3.3.17.0 Component: Aut2Exe
Version: 3.3.16.1 Severity: None
Keywords: Cc:

Description (last modified by jchd18)

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 Changed 16 months ago by jchd18

  • Description modified (diff)

comment:2 Changed 16 months ago by jchd18

  • Summary changed from Witn..EndWith should error out when associated with a DllStruct to With..EndWith should error out when associated with a DllStruct

comment:3 Changed 16 months ago by Jpm

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

comment:4 follow-up: Changed 16 months ago by anonymous

doesn't address the memory leak though

comment:5 in reply to: ↑ 4 Changed 16 months ago by anonymous

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 Changed 16 months ago by Jpm

  • Milestone set to 3.3.17.0
  • Owner set to Jpm
  • Resolution set to Fixed
  • Status changed from new to closed

Fixed by revision [12890] in version: 3.3.17.0

comment:7 follow-up: Changed 16 months ago by anonymous

Does that fix the memory leak or does it just prevent returning struct members from within a With?

comment:8 in reply to: ↑ 7 Changed 16 months ago by Jpm

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

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The owner will remain Jpm.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.