Skip to content

Commit d805eb9

Browse files
committed
COMMON: Fixed memory issue related to SUB/FUNC pointers
1 parent dfce4bd commit d805eb9

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/common/scan.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3091,13 +3091,15 @@ void comp_pass2_scan() {
30913091
case kwTYPE_CALL_UDP:
30923092
case kwTYPE_CALL_UDF:
30933093
memcpy(&label_id, comp_prog.ptr + node->pos + 1, ADDRSZ);
3094-
if (label_id != kwCALLCF) {
3094+
if (label_id < comp_udpcount) {
30953095
// update real IP
30963096
true_ip = comp_udptable[label_id].ip + (ADDRSZ + 3);
30973097
memcpy(comp_prog.ptr + node->pos + 1, &true_ip, ADDRSZ);
30983098
// update return-var ID
30993099
true_ip = comp_udptable[label_id].vid;
31003100
memcpy(comp_prog.ptr + node->pos + (ADDRSZ + 1), &true_ip, ADDRSZ);
3101+
} else if (label_id != kwCALLCF) {
3102+
sc_raise(MSG_EXP_GENERR);
31013103
}
31023104
break;
31033105

@@ -3503,7 +3505,6 @@ void comp_close() {
35033505
*/
35043506
char *comp_load(const char *file_name) {
35053507
char *buf;
3506-
35073508
strcpy(comp_file_name, file_name);
35083509
#if defined(IMPL_DEV_READ)
35093510
buf = dev_read(file_name);

src/languages/messages.en.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
#define MSG_CANT_OPEN_FILE_AT "Can't open '%s' at '%s'\n"
9090
#define MSG_CANT_OPEN_FILE "Can't open '%s'\n"
9191
#define MSG_GRMODE_ERR "GRMODE, usage:<width>x<height>[x<bits-per-pixel>]\nExample: OPTION PREDEF GRMODE=640x480x4\n"
92-
#define MSG_UNIT_NOT_FOUND "Unit %s.sbu not found"
92+
#define MSG_UNIT_NOT_FOUND "Unit %s.sbu not found or wrong version"
9393
#define MSG_IMPORT_FAILED "Unit %s.sbu, import failed"
9494
#define MSG_INVALID_UNIT_NAME "Invalid unit name"
9595
#define MSG_UNIT_ALREADY_DEFINED "Unit name already defined"

0 commit comments

Comments
 (0)