otland / forgottenserver

A free and open-source MMORPG server emulator written in C++
https://otland.net
GNU General Public License v2.0
1.55k stars 1.04k forks source link

[Bug]: Going 'sleep' MAY crash server #4752

Open gesior opened 3 weeks ago

gesior commented 3 weeks ago

By submitting this bug issue, you agree to the following.

Does this bug crash tfs?

yes (not always)

Server Version

1.7 (Master)

Operation System

all (listed below)

OS Description

No response

Bug description

Going 'sleep' MAY crash server

Possible Pull Requests which are to blame

No response

Steps to reproduce

  1. Click on bed (can't check it on 12+, but it may execute C++ action pointed in Actual Behavior)
  2. Wait until someone 'wrap' bed item.
  3. Try to start sleep.

Actual Behavior

I get report from modified TFS. I cannot run 12+ client on Linux. Can someone confirm it?

This: https://github.com/otland/forgottenserver/blob/master/src/actions.cpp#L337 sets bedItem in Player to BedItem*: https://github.com/otland/forgottenserver/blob/master/src/player.h#L226 but does not 'increase pointer' [old TFS] (or use Shared Pointer).

If it opens Dialog window and in meanwhile someone 'Wrap' BedItem (remove ite), it will crash, when someone close Dialog around that line: https://github.com/otland/forgottenserver/blob/master/src/game.cpp#L5655

Expected Behavior

Not crash.

Backtrace

No response