struct atom_node *node;
unsigned int fingerprint;
- if (!string)
+ if (!string || len == 0)
return XKB_ATOM_NONE;
if (find_node_pointer(table, string, len, &nodep, &fingerprint)) {
node->string = UNCONSTIFY(string);
}
else {
- node->string = strdup(string);
+ node->string = strndup(string, len);
if (!node->string) {
free(node);
return XKB_ATOM_NONE;
main(void)
{
struct xkb_context *context = test_get_context(0);
+ xkb_atom_t atom;
assert(context);
assert(!xkb_context_include_path_append(context, "¡NONSENSE!"));
assert(xkb_context_num_include_paths(context) == 1);
+ atom = xkb_atom_intern(context, "HELLOjunkjunkjunk", 5);
+ assert(atom != XKB_ATOM_NONE);
+ assert(streq(xkb_atom_text(context, atom), "HELLO"));
+
+ atom = xkb_atom_intern_literal(context, "HELLOjunkjunkjunk");
+ assert(atom != XKB_ATOM_NONE);
+ assert(streq(xkb_atom_text(context, atom), "HELLOjunkjunkjunk"));
+
xkb_context_unref(context);
return 0;