Skip to content

Commit

Permalink
#416 Result values were copied incorrectly
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderMertens committed Dec 3, 2015
1 parent 4410592 commit 18212e8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
16 changes: 8 additions & 8 deletions packages/corto/lang/include/corto__api.h
Original file line number Diff line number Diff line change
Expand Up @@ -2289,12 +2289,12 @@ CORTO_LANG_EXPORT corto_function* corto_vtableAppendAlloc(corto_vtable *seq);
CORTO_LANG_EXPORT void corto_vtableSize(corto_vtable *seq, corto_uint32 length);
CORTO_LANG_EXPORT void corto_vtableClear(corto_vtable *seq);
#define corto_resultIterForeach(iter, elem) \
while(corto_iterHasNext(&elem##_iter) ? corto_result *elem;\
elem = *(corto_result*)(corto_word)corto_iterNext(&iter), TRUE : FALSE)
#ifdef __cplusplus
}
#endif
#endif
corto_result elem;\
while(corto_iterHasNext(&iter) ? elem = *(corto_result*)(corto_word)corto_iterNext(&iter), TRUE : FALSE)


#ifdef __cplusplus
}
#endif
#endif

5 changes: 5 additions & 0 deletions packages/corto/lang/src/corto_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,11 @@ corto_int16 corto_define(corto_object o) {
void corto_delete(corto_object o) {
corto__object* _o;
corto__scope* scope;

if (!o) {
corto_critical("NULL passed to corto_delete");
}

corto_type t = corto_typeof(o);

if (corto_checkAttr(o, CORTO_ATTR_SCOPED)) {
Expand Down
4 changes: 2 additions & 2 deletions packages/corto/lang/src/corto_select.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,12 +415,12 @@ static void corto_selectIterateReplicators(
data->item.name[0] = '\0';
}
if (result->parent) {
strcpy(data->item.parent, result->name);
strcpy(data->item.parent, result->parent);
} else {
data->item.parent[0] = '\0';
}
if (result->type) {
strcpy(data->item.type, result->name);
strcpy(data->item.type, result->type);
} else {
data->item.type[0] = '\0';
}
Expand Down
13 changes: 8 additions & 5 deletions packages/corto/lang/test/src/test_ReplicatorRequest.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ corto_void _test_ReplicatorRequest_setup(test_ReplicatorRequest this) {

/* Create list of dummy 'remote' objects */
corto_resultList items = corto_llNew();
*(corto_resultListAppendAlloc(items)) = (corto_result){corto_strdup("x")};
*(corto_resultListAppendAlloc(items)) = (corto_result){
corto_strdup("x"),
corto_strdup("parent"),
corto_strdup("type")};
*(corto_resultListAppendAlloc(items)) = (corto_result){corto_strdup("yz")};
*(corto_resultListAppendAlloc(items)) = (corto_result){corto_strdup("xyz")};

Expand All @@ -43,8 +46,8 @@ corto_void _test_ReplicatorRequest_tc_selectScope(test_ReplicatorRequest this) {
test_assert(result != NULL);
test_assert(result->name != NULL);
test_assert(!strcmp(result->name, "x"));
test_assert(!strlen(result->parent));
test_assert(!strlen(result->type));
test_assert(!strcmp(result->parent, "parent"));
test_assert(!strcmp(result->type, "type"));

test_assert(corto_iterHasNext(&iter));
result = corto_iterNext(&iter);
Expand Down Expand Up @@ -145,8 +148,8 @@ corto_void _test_ReplicatorRequest_tc_selectScopeMixed(test_ReplicatorRequest th
test_assert(result != NULL);
test_assert(result->name != NULL);
test_assert(!strcmp(result->name, "x"));
test_assert(!strlen(result->parent));
test_assert(!strlen(result->type));
test_assert(!strcmp(result->parent, "parent"));
test_assert(!strcmp(result->type, "type"));

test_assert(corto_iterHasNext(&iter));
result = corto_iterNext(&iter);
Expand Down

0 comments on commit 18212e8

Please sign in to comment.