Issue information

Issue ID
#4565
Status
Fixed
Severity
Critical
Started
Hercules Elf Bot
Nov 24, 2010 9:52
Last Post
Hercules Elf Bot
Nov 24, 2010 9:52
Confirmation
N/A

Hercules Elf Bot - Nov 24, 2010 9:52

Originally posted by [b]Ai4rei[/b]
http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=4565

Currently there is an issue in script command getusers, causing the map-server to crash, when the command is called with parameter 0 and without attached player.

CODE
BUILDIN_FUNC(getusers)
{
    int flag=script_getnum(st,2);
    struct block_list *bl=map_id2bl((flag&0x08)?st->oid:st->rid);
    int val=0;
    switch(flag&0x07){
    case 0: val=map[bl->m].users; break;  // bl==NULL
    case 1: val=map_getusers(); break;
    }
    script_pushint(st,val);
    return 0;
}


map_id2bl return value is not checked, whether it is NULL or not, and causes access violation on bl->m then.

CODE
prontera,150,150,0    script    TestNPC    123,{
    detachrid;
    getusers 0;
    end;
}