Skip to content

Commit

Permalink
Double free fix when zd_main hands control back to Obsidian
Browse files Browse the repository at this point in the history
Tweaks for cross-platform compilation
  • Loading branch information
dashodanger committed Jul 28, 2021
1 parent 997d143 commit 3557906
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 25 deletions.
2 changes: 2 additions & 0 deletions source_files/ff_src/lex.yy.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,11 @@ char *yytext;
#define INITIAL 0

/*windows compatibility case*/
#if WIN32
#include <io.h>
#define isatty _isatty
#define fileno _fileno
#endif

#ifndef YY_EXTRA_TYPE
#define YY_EXTRA_TYPE void *
Expand Down
21 changes: 2 additions & 19 deletions source_files/gui/g_doom.cc
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ int DM_NumThings() {

#include "zdmain.h"

static bool DM_BuildNodes(const char *filename, const char *out_name) {
static bool DM_BuildNodes(const char *filename) {
LogPrintf("\n");

zdbsp_options options;
Expand Down Expand Up @@ -894,7 +894,6 @@ static bool DM_BuildNodes(const char *filename, const char *out_name) {
if (!UDMF_mode) {
if (!build_nodes) {
LogPrintf("Skipping nodes per user selection...\n");
FileRename(filename, out_name);
return true;
}
}
Expand All @@ -913,7 +912,6 @@ static bool DM_BuildNodes(const char *filename, const char *out_name) {
} else if (current_engine == "zdoom") {
if (!build_nodes) {
LogPrintf("Skipping nodes per user selection...\n");
FileRename(filename, out_name);
return true;
}
options.build_nodes = true;
Expand All @@ -935,8 +933,6 @@ static bool DM_BuildNodes(const char *filename, const char *out_name) {
return false;
}

FileRename(filename, out_name);

return true;
}

Expand Down Expand Up @@ -1033,21 +1029,8 @@ bool doom_game_interface_c::Start(const char *preset) {
}

bool doom_game_interface_c::BuildNodes() {
char *temp_name = ReplaceExtension(filename, "tmp");

FileDelete(temp_name);

if (!FileRename(filename, temp_name)) {
LogPrintf("WARNING: could not rename file to .TMP!\n");
StringFree(temp_name);
return false;
}

bool result = DM_BuildNodes(temp_name, filename);

FileDelete(temp_name);

StringFree(temp_name);
bool result = DM_BuildNodes(filename);

return result;
}
Expand Down
2 changes: 2 additions & 0 deletions source_files/gui/headers.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
#define __OBLIGE_INCLUDES_H__

// we C++
#ifndef NULL
#define NULL nullptr
#endif

/* OS specifics */
#ifdef WIN32
Expand Down
4 changes: 0 additions & 4 deletions source_files/gui/sys_macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@

// basic macros

#ifndef NULL
#define NULL ((void *)0)
#endif

#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
Expand Down
2 changes: 0 additions & 2 deletions source_files/zdbsp_src/zdwad.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ void FWadReader::Close() {
}

FWadReader::~FWadReader() {
if (File) fclose(File);
if (Lumps) delete[] Lumps;
}

bool FWadReader::IsIWAD() const { return Header.Magic[0] == 'I'; }
Expand Down

0 comments on commit 3557906

Please sign in to comment.