summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-07-07 18:37:56 +0300
committerAndrei Karas <akaras@inbox.ru>2016-07-08 20:08:53 +0300
commitae15c696cb055977f535baf7797ae92749eeab34 (patch)
tree4f6e8858b14f6ae2798c02fa450135c0c158dea7
parentc9e6740ae4194a8890d2369b0efb9ae9346f8d7e (diff)
downloadhercules-ae15c696cb055977f535baf7797ae92749eeab34.tar.gz
hercules-ae15c696cb055977f535baf7797ae92749eeab34.tar.bz2
hercules-ae15c696cb055977f535baf7797ae92749eeab34.tar.xz
hercules-ae15c696cb055977f535baf7797ae92749eeab34.zip
Add missing checks into script.c (incomplete)
-rw-r--r--src/map/script.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/map/script.c b/src/map/script.c
index ed38ed1c5..dd7f5dd99 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -83,12 +83,15 @@
struct script_interface script_s;
struct script_interface *script;
+static inline int GETVALUE(const struct script_buf *buf, int i) __attribute__((nonnull (1));
static inline int GETVALUE(const struct script_buf *buf, int i)
{
Assert_ret(VECTOR_LENGTH(*buf) > i + 2);
return (int)MakeDWord(MakeWord(VECTOR_INDEX(*buf, i), VECTOR_INDEX(*buf, i+1)),
MakeWord(VECTOR_INDEX(*buf, i+2), 0));
}
+
+static inline void SETVALUE(struct script_buf *buf, int i, int n) __attribute__((nonnull (1))
static inline void SETVALUE(struct script_buf *buf, int i, int n)
{
Assert_retv(VECTOR_LENGTH(*buf) > i + 2);
@@ -158,6 +161,7 @@ const char* script_op2name(int op) {
static void script_dump_stack(struct script_state* st)
{
int i;
+ nullpo_retv(st);
ShowMessage("\tstart = %d\n", st->start);
ShowMessage("\tend = %d\n", st->end);
ShowMessage("\tdefsp = %d\n", st->stack->defsp);
@@ -200,6 +204,7 @@ static void script_dump_stack(struct script_state* st)
void script_reportsrc(struct script_state *st) {
struct block_list* bl;
+ nullpo_retv(st);
if( st->oid == 0 )
return; //Can't report source.
@@ -304,7 +309,7 @@ void script_reportfunc(struct script_state* st)
/*==========================================
* Output error message
*------------------------------------------*/
-static void disp_error_message2(const char *mes,const char *pos,int report) analyzer_noreturn;
+static void disp_error_message2(const char *mes,const char *pos,int report) __attribute__((nonnull (1))) analyzer_noreturn;
static void disp_error_message2(const char *mes,const char *pos,int report) {
script->error_msg = aStrdup(mes);
script->error_pos = pos;
@@ -333,6 +338,7 @@ void check_event(struct script_state *st, const char *evt)
unsigned int calc_hash(const char* p) {
unsigned int h;
+ nullpo_ret(p);
#if defined(SCRIPT_HASH_DJB2)
h = 5381;
while( *p ) // hash*33 + c
@@ -368,6 +374,7 @@ unsigned int calc_hash_ci(const char* p) {
unsigned int h = 0;
#ifdef ENABLE_CASE_CHECK
+ nullpo_ret(p);
#if defined(SCRIPT_HASH_DJB2)
h = 5381;
while( *p ) // hash*33 + c
@@ -422,8 +429,10 @@ int script_search_str(const char* p)
return -1;
}
-void script_casecheck_clear_sub(struct casecheck_data *ccd) {
+void script_casecheck_clear_sub(struct casecheck_data *ccd)
+{
#ifdef ENABLE_CASE_CHECK
+ nullpo_retv(ccd);
if (ccd->str_data) {
aFree(ccd->str_data);
ccd->str_data = NULL;
@@ -453,6 +462,7 @@ const char *script_casecheck_add_str_sub(struct casecheck_data *ccd, const char
#ifdef ENABLE_CASE_CHECK
int len;
int h = script->calc_hash_ci(p);
+ nullpo_retr(NULL, ccd);
if (ccd->str_hash[h] == 0) {
//empty bucket, add new node here
ccd->str_hash[h] = ccd->str_num;
@@ -638,6 +648,8 @@ void add_scripti(int a)
script->addb(a|0x80);
}
+//------------------------ stop here
+
/**
* Appends a script->str_data object (label/function/variable/integer) to the script buffer.
*