Skip to content

Commit

Permalink
prevent segfault when null string used as hash key
Browse files Browse the repository at this point in the history
  • Loading branch information
timo committed Nov 11, 2016
1 parent 4c9fd00 commit 2817993
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/6model/reprs/MVMHash.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ static MVMObject * type_object_for(MVMThreadContext *tc, MVMObject *HOW) {
}

MVM_STATIC_INLINE void extract_key(MVMThreadContext *tc, void **kdata, size_t *klen, MVMObject *key) {
MVM_HASH_EXTRACT_KEY(tc, kdata, klen, key, "MVMHash representation requires MVMString keys")
MVM_HASH_EXTRACT_KEY(tc, kdata, klen, key, "MVMHash representation requires defined MVMString keys")
}

/* Copies the body of one object to another. */
Expand Down
2 changes: 1 addition & 1 deletion src/6model/reprs/MVMHash.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const MVMREPROps * MVMHash_initialize(MVMThreadContext *tc);
MVM_HASH_ACTION_SELECT_CACHE(tc, hash, name, entry, HASH_FIND_CACHE)

#define MVM_HASH_EXTRACT_KEY(tc, kdata, klen, key, error) \
if (REPR(key)->ID == MVM_REPR_ID_MVMString && IS_CONCRETE(key)) { \
if (!MVM_is_null(tc, (MVMObject *)key) && REPR(key)->ID == MVM_REPR_ID_MVMString && IS_CONCRETE(key)) { \
MVM_string_flatten(tc, (MVMString *)key); \
*kdata = ((MVMString *)key)->body.storage.blob_32; \
*klen = ((MVMString *)key)->body.num_graphs * sizeof(MVMGrapheme32); \
Expand Down

0 comments on commit 2817993

Please sign in to comment.