summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
authorshennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-08-15 12:21:23 +0000
committershennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-08-15 12:21:23 +0000
commit1b90eeba2222378f3f6cdb46e7d805db4c7e7329 (patch)
tree683fead485082ffdad11e39816760c35da4c7887 /src/map/script.c
parent527f90ae1d50ff02bf7784c5b25550f2a9373456 (diff)
downloadhercules-1b90eeba2222378f3f6cdb46e7d805db4c7e7329.tar.gz
hercules-1b90eeba2222378f3f6cdb46e7d805db4c7e7329.tar.bz2
hercules-1b90eeba2222378f3f6cdb46e7d805db4c7e7329.tar.xz
hercules-1b90eeba2222378f3f6cdb46e7d805db4c7e7329.zip
Fixed bugreport:6446 credits to flaviojs, special thanks to Lelouch vi Britannia for the dump.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16638 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/map/script.c b/src/map/script.c
index 50740cb9a..e33e1c643 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -13331,19 +13331,17 @@ BUILDIN_FUNC(charislower)
//=======================================================
// charat <str>, <index>
//-------------------------------------------------------
-BUILDIN_FUNC(charat)
-{
+BUILDIN_FUNC(charat) {
const char *str = script_getstr(st,2);
int pos = script_getnum(st,3);
- char *output;
-
- output = (char*)aMalloc(2*sizeof(char));
- output[0] = '\0';
-
- if(str && pos >= 0 && (unsigned int)pos < strlen(str))
- sprintf(output, "%c", str[pos]);
-
- script_pushstr(st, output);
+
+ if( pos >= 0 && (unsigned int)pos < strlen(str) ) {
+ char output[2];
+ output[0] = str[pos];
+ output[1] = '\0';
+ script_pushstrcopy(st, output);
+ } else
+ script_pushconststr(st, "");
return 0;
}