forked from osmocom/wireshark
Fix usage of g_ascii_strdown() and g_ascii_strup() - they do *not*
modify the string in place, they return a g_mallocated modified version of the string passed into them. svn path=/trunk/; revision=40727
This commit is contained in:
parent
3d3346bc7e
commit
6f59700722
|
@ -511,7 +511,10 @@ static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out
|
|||
#define UAT_PROTO_DEF(basename, field_name, dissector_field, name_field, rec_t) \
|
||||
static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, unsigned len, const void* u1 _U_, const void* u2 _U_) {\
|
||||
if (len) { \
|
||||
((rec_t*)rec)->name_field = g_strndup(buf,len); g_ascii_strdown(((rec_t*)rec)->name_field, -1); g_strchug(((rec_t*)rec)->name_field); \
|
||||
gchar *tmp = g_strndup(buf,len); \
|
||||
((rec_t*)rec)->name_field = g_ascii_strdown(tmp, -1); \
|
||||
g_free(tmp); \
|
||||
g_strchug(((rec_t*)rec)->name_field); \
|
||||
((rec_t*)rec)->dissector_field = find_dissector(((rec_t*)rec)->name_field); \
|
||||
} else { \
|
||||
((rec_t*)rec)->dissector_field = find_dissector("data"); \
|
||||
|
|
|
@ -1140,17 +1140,18 @@ WSLUA_CONSTRUCTOR Proto_new(lua_State* L) {
|
|||
const gchar* desc = luaL_checkstring(L,WSLUA_ARG_Proto_new_DESC);
|
||||
|
||||
if ( name ) {
|
||||
gchar* loname_a = ep_strdup(name);
|
||||
g_ascii_strdown(loname_a, -1);
|
||||
if ( proto_get_id_by_filter_name(loname_a) > 0 ) {
|
||||
gchar* loname_a;
|
||||
int proto_id;
|
||||
|
||||
loname_a = g_ascii_strdown(name, -1);
|
||||
proto_id = proto_get_id_by_filter_name(loname_a);
|
||||
g_free(loname_a);
|
||||
if ( proto_id > 0 ) {
|
||||
WSLUA_ARG_ERROR(Proto_new,NAME,"there cannot be two protocols with the same name");
|
||||
} else {
|
||||
Proto proto = g_malloc(sizeof(wslua_proto_t));
|
||||
gchar* loname = g_strdup(name);
|
||||
gchar* hiname = g_strdup(name);
|
||||
|
||||
g_ascii_strdown(loname, -1);
|
||||
g_ascii_strup(hiname, -1);
|
||||
gchar* loname = g_ascii_strdown(name, -1);
|
||||
gchar* hiname = g_ascii_strup(name, -1);
|
||||
|
||||
proto->name = hiname;
|
||||
proto->desc = g_strdup(desc);
|
||||
|
@ -1236,8 +1237,7 @@ static int Proto_set_dissector(lua_State* L) {
|
|||
|
||||
if (lua_isfunction(L,3)) {
|
||||
/* insert the dissector into the dissectors table */
|
||||
gchar* loname = g_strdup(proto->name);
|
||||
g_ascii_strdown(loname, -1);
|
||||
gchar* loname = g_ascii_strdown(proto->name, -1);
|
||||
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, lua_dissectors_table_ref);
|
||||
lua_replace(L, 1);
|
||||
|
|
Loading…
Reference in New Issue