diff options
author | Andrei Karas <akaras@inbox.ru> | 2020-05-21 01:35:57 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2020-06-01 01:08:50 +0300 |
commit | 8f151ab584cef0adf96c5cbcac6c2ace97bf4484 (patch) | |
tree | 18436226790169d2887a127d45de4ab5c0bf3165 /src | |
parent | b648e49e821760502b5b5ae826b194c98b17d529 (diff) | |
download | hercules-8f151ab584cef0adf96c5cbcac6c2ace97bf4484.tar.gz hercules-8f151ab584cef0adf96c5cbcac6c2ace97bf4484.tar.bz2 hercules-8f151ab584cef0adf96c5cbcac6c2ace97bf4484.tar.xz hercules-8f151ab584cef0adf96c5cbcac6c2ace97bf4484.zip |
Fix wrong memory access in party_broken
Diffstat (limited to 'src')
-rw-r--r-- | src/map/party.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/map/party.c b/src/map/party.c index 7d7f69620..8eeae2215 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -677,17 +677,18 @@ static int party_member_withdraw(int party_id, int account_id, int char_id) /// Invoked (from char-server) when a party is disbanded. static int party_broken(int party_id) { - struct party_data* p; - int i, j; + int i; - p = party->search(party_id); - if( p == NULL ) + struct party_data *p = party->search(party_id); + if (p == NULL) return 0; - for( j = 0; j < p->instances; j++ ) { - if( p->instance[j] >= 0 ) { - instance->destroy( p->instance[j] ); - instance->list[p->instance[j]].owner_id = 0; + for (int j = 0; j < p->instances; j++) { + const short instance_id = p->instance[j]; + if (instance_id >= 0) { + instance->destroy(instance_id); + if (instance_id < instance->instances) + instance->list[instance_id].owner_id = 0; } } |