07-27-2024, 07:15 AM
I've run across a bug(s) with variable length strings nested within a UDT.
It manifested itself when I had some variables that originate from a UDT that should have been initialized to zero, but were instead a random value.
This is a stripped down example of the issue(s).
Its seems that if you nest a variable length string in a UDT It can causes crashes.
Variable length strings in this case is convenient for me because the LEN function reports the actual length of string, not the allocated block of memory. This makes the string parsing and manipulation easier.
The workaround would to use fixed length strings and roll my own LEN function.
I'm using Linux and QB v3.13.0
It manifested itself when I had some variables that originate from a UDT that should have been initialized to zero, but were instead a random value.
This is a stripped down example of the issue(s).
Its seems that if you nest a variable length string in a UDT It can causes crashes.
Variable length strings in this case is convenient for me because the LEN function reports the actual length of string, not the allocated block of memory. This makes the string parsing and manipulation easier.
The workaround would to use fixed length strings and roll my own LEN function.
I'm using Linux and QB v3.13.0
Code: (Select All)
'Nested String UDT Issues
TYPE tUDT_NEST_DEEPER
'If I comment out the 'a' element, and the element 's' is not
' a fixed length, the elements do not initialize to zero properly.
a AS LONG
's AS STRING * 10 ' Works with no issue
s AS STRING ' broken
b AS LONG
END TYPE
TYPE tUDTNEST
s AS STRING
n AS LONG
u AS tUDT_NEST_DEEPER
END TYPE
TYPE tUDT
a AS LONG
b AS tUDTNEST
c AS LONG
END TYPE
DIM test AS tUDT
'The following should initialize to 0 or blank
PRINT " These should all be zero or blank."
PRINT "test.a = "; test.a
PRINT "test.b.s = "; test.b.s
PRINT "test.b.n = "; test.b.n
PRINT "test.c = "; test.c
'Uncomment for crash, if you are using variable length strings
'PRINT "test.b.u.s = "; test.b.u.s
'PRINT "test.b.u.b = "; test.b.u.b
2D physics engine https://github.com/mechatronic3000/fzxNGN
Untitled Rouge-like https://github.com/mechatronic3000/Untitled-Rougelike
QB Pool https://github.com/mechatronic3000/QBPool
Untitled Rouge-like https://github.com/mechatronic3000/Untitled-Rougelike
QB Pool https://github.com/mechatronic3000/QBPool