id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc 91,addMapToMap function,Knut Landmark,,"The `addMapToMap(map** mo, map* mi)` function (service.h) should append `mi` to the last node in `mo`. However, the function does not work as intended. In the following code fragment, the pointer `_cursor` is detached from the linked list `mo` when `createMap` is called. As a consequence, `addMapToMap` only modifies `mo` when `*mo == NULL`. {{{ map* _cursor=*mo; /* .... */ while(_cursor!=NULL) _cursor=_cursor->next; _cursor=createMap(tmp->name,tmp->value); // _cursor no longer points to node in mo linked list _cursor->next=NULL; // superfluous }}} This problem affects, in the least, the support for PHP. See specifically the function `map* php_map_from_HasTable(HashTable* t)` (service_internal_php.c): The line {{{ addMapToMap(&final_res, createMap(key,Z_STRVAL(tmpcopy))); }}} occurs inside a loop over the attributes of an output variable, but a node will only be added to `final_res` in the first iteration of the loop, i.e. only the first attribute will be included. Thus if the first attribute is not `value`, the WPS process fails. I have written a modified `addMapToMap` function (see below) which resolved the problems with our PHP services (it should be verified independently that the modified function works as required). {{{ static void addMapToMap( map** mo, map* mi ) { if ( mo != NULL && mi != NULL ) { map* p_mi = mi; if ( *mo == NULL ) { *mo = createMap( mi->name, mi->value ); p_mi = mi->next; } // move to end of *mo linked list map* p_mo = *mo; while ( p_mo->next != NULL ) { p_mo = p_mo->next; } // add nodes in mi linked list sequentially while ( p_mi != NULL ) { p_mo->next = createMap( p_mi->name, p_mi->value ); p_mi = p_mi->next; p_mo = p_mo->next; } } } }}} ",defect,new,major,,zoo-kernel,,,,