* xmlBuildQName: * @ncname: the Name * @prefix: the prefix * @memory: preallocated memory * @len: preallocated memory length * * Builds the QName @prefix:@ncname in @memory if there is enough space * and prefix is not NULL nor empty, otherwise allocate a new string. * If prefix is NULL or empty it returns ncname. * * Returns the new string which must be freed by the caller if differe
| 165 | * @memory and @ncname or NULL in case of error |
| 166 | */ |
| 167 | xmlChar * |
| 168 | xmlBuildQName(const xmlChar *ncname, const xmlChar *prefix, |
| 169 | xmlChar *memory, int len) { |
| 170 | int lenn, lenp; |
| 171 | xmlChar *ret; |
| 172 | |
| 173 | if (ncname == NULL) return(NULL); |
| 174 | if (prefix == NULL) return((xmlChar *) ncname); |
| 175 | |
| 176 | #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION |
| 177 | /* Make allocation more likely */ |
| 178 | if (len > 8) |
| 179 | len = 8; |
| 180 | #endif |
| 181 | |
| 182 | lenn = strlen((char *) ncname); |
| 183 | lenp = strlen((char *) prefix); |
| 184 | |
| 185 | if ((memory == NULL) || (len < lenn + lenp + 2)) { |
| 186 | ret = (xmlChar *) xmlMallocAtomic(lenn + lenp + 2); |
| 187 | if (ret == NULL) |
| 188 | return(NULL); |
| 189 | } else { |
| 190 | ret = memory; |
| 191 | } |
| 192 | memcpy(&ret[0], prefix, lenp); |
| 193 | ret[lenp] = ':'; |
| 194 | memcpy(&ret[lenp + 1], ncname, lenn); |
| 195 | ret[lenn + lenp + 1] = 0; |
| 196 | return(ret); |
| 197 | } |
| 198 | |
| 199 | /** |
| 200 | * xmlSplitQName2: |
no outgoing calls
no test coverage detected