Skip to content

Validate before allocating WFIFO buffer, not after - #3435

Open
MrKeiKun wants to merge 1 commit into
HerculesWS:masterfrom
MrKeiKun:fix/issue-1041-return-before-wfifoset
Open

Validate before allocating WFIFO buffer, not after#3435
MrKeiKun wants to merge 1 commit into
HerculesWS:masterfrom
MrKeiKun:fix/issue-1041-return-before-wfifoset

Conversation

@MrKeiKun

Copy link
Copy Markdown
Contributor

Pull Request Prelude

Changes Proposed

Several functions called WFIFOHEAD before finishing validation/data-gathering, then returned without calling WFIFOSET. Reordered so checks happen first and the buffer is only allocated once a packet is actually going to be sent:

  • chrif_save_scdata: count active status changes before allocating.
  • chrif_update_ip: check whether the IP changed before allocating.
  • clif_updatestatus: reject an unrecognized type before allocating (added a validation switch mirroring the real switch's case labels, since the valid values aren't a contiguous range).
  • clif_use_card: count insertable items before allocating.
  • clif_sendegg: count hatchable pet eggs before allocating.

Issues addressed: #1041

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant