| 08-17-2006, 11:57 PM | #1 |
I was using some code in a trigger and found that my thread crashes if a unit variable is never pointed to anything and you check if it is null. For example: JASS:function nullTest takes nothing returns nothing local unit u if u == null then call BJDebugMsg("null") else call BJDebugMsg("not null") endif call BJDebugMsg("end thread") endfunction I get none of the messages from this because of checking if u==null. I assumed that it was null if never pointed in the first place. However, this won't crash: JASS:function GroupBool takes nothing returns boolean return IsUnitType(GetFilterUnit(),UNIT_TYPE_HERO) endfunction function group_test_Actions takes nothing returns nothing local group g=CreateGroup() call GroupEnumUnitsOfPlayer(g,Player(2),Condition(function GroupBool)) if FirstOfGroup(g)==null then call BJDebugMsg("null") else call BJDebugMsg("not null") endif call BJDebugMsg("end") endfunction |
| 08-18-2006, 12:01 AM | #2 |
Trying to read any uninitialized variable is a recipe for crash. |
| 08-18-2006, 07:40 AM | #3 |
That was known ages before. |
