Skip to content

Commit 9a98bfa

Browse files
authored
Merge pull request #331 from icosahedral-dragon/fix-asan-errors
Fix asan errors
2 parents 57be51d + f4e006e commit 9a98bfa

File tree

12 files changed

+17
-16
lines changed

12 files changed

+17
-16
lines changed

Diff for: src/GameSrc/Headers/cyber.h

+3
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ errtype check_cspace_death();
4848
#define CYBERMINE_DAMAGE 15
4949
#define CYBERHEAL_QUANTITY 70
5050

51+
// Time until SHODAN appears to kick the player out of cyberspace.
52+
extern uint32_t time_until_shodan_avatar;
53+
5154
extern void (*cspace_effect_turnoff[])(uchar, uchar);
5255
extern ulong cspace_effect_times[NUM_CS_EFFECTS];
5356
extern ulong cspace_effect_durations[NUM_CS_EFFECTS];

Diff for: src/GameSrc/Headers/trigger.h

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ typedef struct _EmailSchedEvent {
8383
ushort timestamp;
8484
ushort type;
8585
short datamunge;
86+
short pad; // must be at least as big as a SchedEvent
8687
} EmailSchedEvent;
8788

8889
// Prototypes

Diff for: src/GameSrc/cyber.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
4848
extern uchar *shodan_bitmask;
4949

5050
ObjID shodan_avatar_id = OBJ_NULL;
51-
extern uint32_t time_until_shodan_avatar;
51+
uint32_t time_until_shodan_avatar = 0;
5252

5353
ObjID cspace_decoy_obj = OBJ_NULL;
5454
ObjLoc recall_objloc;

Diff for: src/GameSrc/gameobj.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,7 @@ void show_obj(ObjID cobjid) {
10711071
case FAUBJ_TPOLY:
10721072
switch (ID2TRIP(cobjid)) {
10731073
case TMAP_TRIPLE: {
1074-
extern int all_textures;
1074+
extern uchar all_textures;
10751075
tpdata = get_texture_map(objBigstuffs[_fr_cobj->specID].data2,
10761076
(all_textures) ? TEXTURE_128_INDEX : TEXTURE_64_INDEX);
10771077
scale = -1;

Diff for: src/GameSrc/gamerend.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2929

3030
#include "tools.h"
3131

32+
#include "cyber.h"
3233
#include "gamerend.h"
3334
#include "weapons.h"
3435
#include "colors.h"
@@ -664,7 +665,6 @@ uchar gamesys_draw_func(void *fake_dest_canvas, void *fake_dest_bm, int x, int y
664665
switch (flags & FR_OVERLAY_MASK) {
665666
case FR_OVERLAY_SHODAN: {
666667
int i;
667-
extern ulong time_until_shodan_avatar;
668668
extern uchar *shodan_bitmask;
669669
extern grs_bitmap shodan_draw_fs;
670670
extern grs_bitmap shodan_draw_normal;

Diff for: src/GameSrc/gamesys.c

-2
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,6 @@ errtype gamesys_run(void) {
500500
}
501501

502502
if (shodan_bitmask != NULL) {
503-
extern uint32_t time_until_shodan_avatar;
504503
if (player_struct.game_time > time_until_shodan_avatar) {
505504
char i;
506505
if (thresh_fail) {
@@ -725,7 +724,6 @@ int apply_rate(int var, int rate, int t0, int t1, int vmin, int vmax) {
725724

726725
#define ENERGY_VAR_RATE 50
727726

728-
uint32_t time_until_shodan_avatar = 0;
729727
extern ObjID shodan_avatar_id;
730728

731729
#define MY_FORALLOBJSPECS(pmo, objspec) \

Diff for: src/GameSrc/hud.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2828
#include <string.h>
2929
#include <stdio.h>
3030

31+
#include "cyber.h"
3132
#include "hud.h"
3233
#include "hudobj.h"
3334
#include "player.h"
@@ -172,7 +173,6 @@ void hud_delete_line(int i) {
172173

173174
void compute_hud_var(HudLine *hl) {
174175
extern short shield_absorb_perc;
175-
extern ulong time_until_shodan_avatar;
176176
extern void second_format(int sec_remain, char *s);
177177

178178
char *text = hudline_text[HUDLINE_TEXT(hl)];

Diff for: src/GameSrc/mfdfunc.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -2331,7 +2331,7 @@ char *level_to_floor(int lev_num, char *buf) {
23312331
return (buf);
23322332
}
23332333

2334-
#define NUMBER_BUFSZ 3
2334+
#define NUMBER_BUFSZ 4 // don't forget the terminator!
23352335

23362336
// if we null your panel_ref, return the value
23372337
// before we nulled it. Otherwise, return NULL.
@@ -2639,8 +2639,6 @@ void mfd_setup_keypad(char special) {
26392639
mfd_notify_func(MFD_KEYPAD_FUNC, MFD_INFO_SLOT, TRUE, MFD_ACTIVE, TRUE);
26402640
}
26412641

2642-
#define NUMBER_BUFSZ 3
2643-
26442642
void mfd_keypad_expose(MFD *mfd, ubyte control) {
26452643
keypad_data_type *keypad_data = (keypad_data_type *)&player_struct.mfd_func_data[MFD_KEYPAD_FUNC][0];
26462644
char buf[NUMBER_BUFSZ];

Diff for: src/GameSrc/trigger.c

-1
Original file line numberDiff line numberDiff line change
@@ -1405,7 +1405,6 @@ grs_bitmap shodan_draw_normal;
14051405

14061406
void hack_shodan_conquer_func(char c) {
14071407
extern void begin_shodan_conquer_fx(uchar begin);
1408-
extern ulong time_until_shodan_avatar;
14091408
extern char thresh_fail;
14101409
extern uchar shodan_phase_in(uchar * bitmask, short x, short y, short w, short h, short num, uchar dir);
14111410
shodan_bitmask = tmap_static_mem;

Diff for: src/Libraries/FIX/Source/MakeTables.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,13 @@ uint16_t sintab[256+64+1] = {
8484
// Its units are fixangs.
8585
//
8686
// acos(x) = PI/2 - asin(x). (PI/2 is fixang 0x4000)
87+
// Note that there are 130 entries in the table. The asin and acos functions
88+
// will use the low 8 bits to interpolate between entry i and entry i+1: if the
89+
// parameter is exactly 1, this will be asintab[128] and asintab[129].
8790

8891
// indexed by (high 8 bits of (fix >> 2 + 0x4000)
8992
// clang-format off
90-
fixang asintab[128+1] = {
93+
fixang asintab[128+1+1] = {
9194
0xc001, 0xc737, 0xca37, 0xcc87, 0xce7c, 0xd037, 0xd1ca, 0xd33d,
9295
0xd498, 0xd5e0, 0xd716, 0xd840, 0xd95d, 0xda6f, 0xdb78, 0xdc7a,
9396
0xdd73, 0xde67, 0xdf54, 0xe03c, 0xe11e, 0xe1fd, 0xe2d7, 0xe3ad,
@@ -104,7 +107,7 @@ fixang asintab[128+1] = {
104107
0x1b82, 0x1c54, 0x1d2a, 0x1e04, 0x1ee3, 0x1fc5, 0x20ad, 0x219a,
105108
0x228e, 0x2387, 0x2489, 0x2592, 0x26a4, 0x27c1, 0x28eb, 0x2a21,
106109
0x2b69, 0x2cc4, 0x2e37, 0x2fca, 0x3185, 0x337a, 0x35ca, 0x38ca,
107-
0x4000
110+
0x4000, 0x4000
108111
};
109112
// clang-format on
110113

Diff for: src/Libraries/FIX/Source/trigtab.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
*/
1919
extern uint16_t sintab[256 + 64 + 1];
2020

21-
extern fixang asintab[128 + 1];
21+
extern fixang asintab[128 + 1 + 1];
2222

2323
#define INTEGER_EXP_OFFSET 11
2424
extern uint32_t expinttab[INTEGER_EXP_OFFSET * 2 + 1];

Diff for: src/Libraries/RES/Source/lzw.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -334,11 +334,10 @@ int32_t LzwCompress(void (*f_SrcCtrl)(intptr_t srcLoc, LzwCtrl ctrl), // func
334334
// the input has been exhausted. Note that it stops adding codes to the
335335
// table after all of the possible codes have been defined.
336336

337-
while (true) {
337+
while (lzwc.lzwInputCharCount < srcSize) {
338338
// Get next input char, if read all data then exit loop
339339
lzwc.character = (*f_SrcGet)();
340-
if (lzwc.lzwInputCharCount++ >= srcSize)
341-
break;
340+
lzwc.lzwInputCharCount++;
342341

343342
// See if string is in string table. If it is, get the code value.
344343
lzwc.index = LzwFindMatch(lzwc.string_code, lzwc.character);

0 commit comments

Comments
 (0)