From 652a86beab80b9d5fa43c502b5e102ae3706e14d Mon Sep 17 00:00:00 2001 From: skotlex Date: Fri, 28 Jul 2006 04:17:24 +0000 Subject: - Fixed a memory leak when there exists more than one user function with the same name, added the appropiate warning when this happens. - Added reporting source file when an npc shops item's price is exploitable. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@7935 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/npc.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/map/npc.c') diff --git a/src/map/npc.c b/src/map/npc.c index 696775cc2..2aee1c58c 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -1625,11 +1625,11 @@ static int npc_parse_shop (char *w1, char *w2, char *w3, char *w4) if (value/124. < id->value_sell/75.) { //Clened up formula to prevent overflows. printf("\r"); //Carriage return to clear the 'loading..' line. [Skotlex] if (value < id->value_sell) - ShowWarning ("Item %s [%d] buying price (%d) is less than selling price (%d)\n", - id->name, id->nameid, value, id->value_sell); + ShowWarning ("Item %s [%d] buying price (%d) is less than selling price (%d) at %s\n", + id->name, id->nameid, value, id->value_sell, current_file); else - ShowWarning ("Item %s [%d] discounted buying price (%d) is less than overcharged selling price (%d)\n", - id->name, id->nameid, value/100*75, id->value_sell/100*124); + ShowWarning ("Item %s [%d] discounted buying price (%d) is less than overcharged selling price (%d) at %s\n", + id->name, id->nameid, value/100*75, id->value_sell/100*124, current_file); } //for logs filters, atcommands and iteminfo script command if (id->maxchance<=0) @@ -2124,7 +2124,13 @@ static int npc_parse_function (char *w1, char *w2, char *w3, char *w4, char *fir strncpy(p, w3, 50); user_db = script_get_userfunc_db(); - strdb_put(user_db, p, script); + if(strdb_get(user_db, p) != NULL) { + printf("\r"); //Carriage return to clear the 'loading..' line. [Skotlex] + ShowWarning("parse_function: Duplicate user function [%s] (%s:%d)\n", p, file, *lines); + aFree(p); + script_free_code(script); + } else + strdb_put(user_db, p, script); // もう使わないのでバッファ解放 aFree(srcbuf); -- cgit v1.2.3-60-g2f50