Subject UDF Problem in Firebird 2
Author thiago_bor
I has a UDF with works fine in Firebird 1.5 and crash the firebird
server 2.0 with a access violation.

I has building the dll in Dev-C++.

The code:

int countespecial(const char* source) {
int i = 0, c = 0;
while (source[i] != '\0') {
if ((source[i] == '\'') || (source[i] == '`')) c++;
i++;
}
return c;
}

__declspec (dllexport) char* strquoted(char* s) {
if (!s) return 0;
char* st = (char*)malloc(1 + strlen(s) + countespecial(s));
int i=0, j=0;
while (s[i] != '\0') {
if ((s[i] == '`') || (s[i] == '\'')) {
st[j++] = '\'';
st[j++] = '\'';
}
else
st[j++] = s[i];
i++;
}
st[j] = '\0';
return st;
}

The sql register code:
DECLARE EXTERNAL FUNCTION STRQUOTED
CSTRING(256)
RETURNS CSTRING(256) FREE_IT
ENTRY_POINT 'strquoted' MODULE_NAME 'testudf'

The crash occurs when i execute five time the statement:
select strquoted('test') from rdb$database

Can someone help-me?
Thanks,

--
Thiago Borges