Skip to content

Commit

Permalink
Fix argument validation issue in file.
Browse files Browse the repository at this point in the history
  • Loading branch information
gabordemooij committed Feb 26, 2018
1 parent 15b295d commit a822cae
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion file.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ctr_object* ctr_file_new(ctr_object* myself, ctr_argument* argumentList) {
s->info.type = CTR_OBJECT_TYPE_OTEX; /* indicates resource for GC */
s->link = myself;
s->value.rvalue = NULL;
pathObject = ctr_build_string( argumentList->object->value.svalue->value, argumentList->object->value.svalue->vlen );
pathObject = ctr_internal_cast2string( argumentList->object );
ctr_internal_object_add_property( s, ctr_build_string_from_cstring( "path" ), pathObject, 0 );
return s;
}
Expand Down
10 changes: 10 additions & 0 deletions tests/test0318.ctr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#test file argument validation

☞ file := File new: File messagedoesnotexist.
☞ file := File new: Nil.
☞ file := File new: 123.
☞ file := File new: True.
☞ file := File new: False.
☞ file := File new: Object.

✎ write: 'I did not crash!', brk.
1 change: 1 addition & 0 deletions tests/test0318.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I did not crash!

0 comments on commit a822cae

Please sign in to comment.