Commit Graph

29 Commits

Author SHA1 Message Date
Louis Gombert
238aead057
Merge pull request #646 from jengelh/spello
Fix spellos in comments/strings
2024-11-25 21:26:54 +00:00
Jan Engelhardt
8e30eea951 Resolve crash on inventory pickup
Commit d185ab9514 broke the
pointer-moving logic. When the allweapons cheat is executed or when
e.g. the afterburner is picked up, ASAN terminates the program with:

```
==8330==ERROR: AddressSanitizer: heap-use-after-free on address 0x50f00007ab60
at pc 0x7f23334f6843 bp 0x7ffe724d2b10 sp 0x7ffe724d22d0
READ of size 3 at 0x50f00007ab60 thread T0
    f0 strdup
    f1 Inventory::AddCounterMeasure(int, int, int, int, char const*) Descent3/Inventory.cpp:575
    f2 Inventory::Add(int, int, object*, int, int, int, char const*) Descent3/Inventory.cpp:520
    f3 DemoCheats(int) Descent3/GameCheat.cpp:606
    f4 ProcessKeys() Descent3/GameLoop.cpp:2420
    f5 GameFrame() Descent3/GameLoop.cpp:2956
    f6 GameSequencer() Descent3/gamesequence.cpp:1212
    f7 PlayGame() Descent3/game.cpp:826
    f8 MainLoop() Descent3/descent.cpp:554
    f9 Descent3() Descent3/descent.cpp:507
    f10 oeD3LnxApp::run() Descent3/sdlmain.cpp:142
    f11 main Descent3/sdlmain.cpp:323

0x50f00007ab60 is located 0 bytes inside of 175-byte region [0x50f00007ab60,0x50f00007ac0f)
freed by thread T0 here:
    f1 mng_LoadNetGenericPage(CFILE*, bool) manage/generic.cpp:2216
    f2 mng_LoadNetPages(int) manage/manage.cpp:1281
    f3 mng_LoadTableFiles(int) manage/manage.cpp:648
    f4 InitD3Systems2(bool) Descent3/init.cpp:1891
    f5 Descent3() Descent3/descent.cpp:503
    f6 oeD3LnxApp::run() Descent3/sdlmain.cpp:142
    f7 main Descent3/sdlmain.cpp:323

previously allocated by thread T0 here:
    f0 malloc
    f1 mem_rmalloc<char> mem/mem.h:138
    f2 mng_ReadNewGenericPage(CFILE*, mngs_generic_page*) manage/generic.cpp:1145
    f3 mng_LoadNetGenericPage(CFILE*, bool) manage/generic.cpp:2196
    f4 mng_LoadNetPages(int) manage/manage.cpp:1281
    f5 mng_LoadTableFiles(int) manage/manage.cpp:648
    f6 InitD3Systems2(bool) Descent3/init.cpp:1891
    f7 Descent3() Descent3/descent.cpp:503
    f8 oeD3LnxApp::run() Descent3/sdlmain.cpp:142
    f9 main Descent3/sdlmain.cpp:323
```

The pointer value of mngs_generic_page::description was copied to
object_info::description (by function
``mng_AssignGenericPageToObjInfo``) and then the page was freed in
``mng_LoadNetGenericPage``, leaving object_info::description non-NULL
and dangling.

Fixes: d185ab9514
2024-11-04 11:02:57 +01:00
Jan Engelhardt
6fb7684a85 Fix spello "rturns" 2024-11-04 10:20:54 +01:00
Azamat H. Hackimov
a59503f881 Move pserror.h to ddebug module 2024-09-24 23:00:53 +03:00
Jan Engelhardt
a23c6a42a3 mem_malloc type triviality checks (7/8)
```
git grep -l mem_malloc | xargs perl -i -lpe 's{\((char) \*\)mem_malloc\((\S+)\)}{mem_rmalloc<$1>($2)}'
```
2024-09-16 22:12:14 +02:00
Louis Gombert
7282af9cd8
Merge pull request #568 from winterheart/valgrind
Fix discovered memory leaks
2024-09-16 20:48:56 +02:00
Azamat H. Hackimov
4259fe4c18 Convert manage to use new logging facility 2024-09-10 03:00:25 +03:00
Azamat H. Hackimov
d185ab9514 Fix memory leaks in dedicated mode 2024-09-04 14:17:02 +03:00
Jan Engelhardt
38b835a03b Fix spello "its" 2024-09-03 13:26:51 +02:00
Jan Engelhardt
a3a31c77a2 Fix spello "seperate.." 2024-09-03 13:26:51 +02:00
Jan Engelhardt
b14470bbff Fix spello "independan.." 2024-09-03 13:26:51 +02:00
Jan Engelhardt
edbde82918 Fix spello "agression" 2024-09-03 13:26:51 +02:00
Jan Engelhardt
234e666ce0 Fix spello "charactor" 2024-09-03 13:26:51 +02:00
Azamat H. Hackimov
3af18dadc3 MANAGE: convert some global path variables to std::fs::path
Simplifies code related to UpdatePrimitive().
2024-07-01 12:50:49 +03:00
Azamat H. Hackimov
a00be9f71a MANAGE: refactor UpdatePrimitive() related code
Use std::fs::path on path construction, simplify code.
2024-07-01 12:50:49 +03:00
GravisZro
9cf9781369 Properly format/use variadic macros 2024-05-24 20:57:17 -04:00
GravisZro
aebe1bbbb6 Replace "ushort" with "uint16_t" and fix missing includes 2024-05-23 23:16:40 -04:00
GravisZro
26b7776f43 Replace "ubyte" with "uint8_t" 2024-05-23 23:07:26 -04:00
JeodC
a4ab78192c Join license header with historical commentrs
Join the license header with historical comments using a separator so IDEs can correctly parse the initial header.

Also use .gitattributes to ensure all files are LF.
2024-05-08 14:41:19 -04:00
Edu García
3440667e93 remove unused code (mainly windows.h) 2024-05-07 23:45:33 +01:00
Chris Sarbora
e6ba1906c9
Remove MacOS (Classic) code and all references (1/3)
The MACINTOSH define refers to MacOS Classic (not OS X) which we do not
plan to support. Rather than carry the cruft forever, let's delete it.

NOTE: legacy/ is unused but we're keeping it around, so MACINTOSH uses
there are left alone.

Process used for this commit:
```
git rm -r mac
find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" \) \
  -exec unifdef -UMACINTOSH -o {} {} \;
git restore legacy
git add .
```

Test Plan:
On Mac, build both Debug and Release
```
cmake --build --preset mac --config Debug
cmake --build --preset mac --config Release
```
2024-04-27 07:38:14 -07:00
Azamat H. Hackimov
4826c37a69 Add BUILD_INTERFACE to cfile module
Other modules that depends on it, can reuse includes on linking.
There some files formally not belonging any packages (lib directory), as workaround there temporary include_directories(cfile) on root of project. After migrating all modules this can be removed.
2024-04-24 00:41:02 +03:00
Azamat H. Hackimov
c275d359c7 Reapply "Cfile module update"
This reverts commit 066b436fd9.
2024-04-24 00:40:39 +03:00
Kevin Bentley
1f45163248 Updated source to reflect the license that this code is released under. 2024-04-20 09:57:49 -06:00
C.W. Betts
7d7f5bf896 Quiet Clang Static Analyzer warnings.
Most of the warnings were caused by uninitialized values. Some were in plug-ins that didn't have a break in a switch, causing the memory to be deleted twice.
2024-04-19 17:42:17 -06:00
Edu Garcia
066b436fd9
Revert "Cfile module update" 2024-04-19 13:57:55 +01:00
Azamat H. Hackimov
9b45091633 Rename/move cfile related files
Rename to lowercase and move headers to own directory.
2024-04-19 00:17:15 +03:00
Kevin Bentley
c6640cc631 clang-format on everything. 2024-04-16 12:56:40 -06:00
Kevin Bentley
df209742fc Initial import 2024-04-15 21:43:29 -06:00