- Applied Rayce's dangling pointer fix when returning a temporary npc string variable (those starting with .@)

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@9864 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
skotlex 2007-02-13 22:27:30 +00:00
parent 74bbb42178
commit 81b4f30221
2 changed files with 8 additions and 0 deletions

View File

@ -4,6 +4,8 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2007/02/13 2007/02/13
* Applied Rayce's dangling pointer fix when returning a temporary npc
string variable (those starting with .@)
* Required Weapon, ammo, and skill state are now only checked on begin * Required Weapon, ammo, and skill state are now only checked on begin
casting, instead of both on begin and end casting. casting, instead of both on begin and end casting.
2007/02/12 2007/02/12

View File

@ -4325,6 +4325,12 @@ BUILDIN_FUNC(return)
if( name[0] == '.' && name[1] == '@') { if( name[0] == '.' && name[1] == '@') {
// '@ 変数を参照渡しにすると危険なので値渡しにする // '@ 変数を参照渡しにすると危険なので値渡しにする
get_val(st,sd); get_val(st,sd);
//Fix dangling pointer crash due when returning a temporary
// script variable (from Rayce/jA)
if(isstr(sd)) {
sd->type = C_STR;
sd->u.str = (char *)aStrdup(sd->u.str);
}
} else if( name[0] == '.' && !sd->ref) { } else if( name[0] == '.' && !sd->ref) {
// ' 変数は参照渡しでも良いが、参照元が設定されていないと // ' 変数は参照渡しでも良いが、参照元が設定されていないと
// 元のスクリプトの値を差してしまうので補正する。 // 元のスクリプトの値を差してしまうので補正する。