Skip to content

Commit

Permalink
kernel: fix crash when tracing buggy attributes/properties
Browse files Browse the repository at this point in the history
If an attribute or property returns nothing (resp. something other than true
or false), this is an error, which we normally catch. But when tracing is
enabled for the relevant operations, we would instead crash.
  • Loading branch information
fingolfin committed Aug 19, 2018
1 parent f33c7d2 commit 29beb57
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/opers.c
Original file line number Diff line number Diff line change
Expand Up @@ -2561,7 +2561,7 @@ Obj DoAttribute (
val = DoOperation1Args( self, obj );
while (val == (Obj) 0) {
val = ErrorReturnObj("Method for an attribute must return a value",
0L, 0L,
0L, 0L,
"you can supply a value <val> via 'return <val>;'");
}
val = CopyObj( val, 0 );
Expand Down Expand Up @@ -2614,6 +2614,11 @@ Obj DoVerboseAttribute (

/* call the operation to compute the value */
val = DoVerboseOperation1Args( self, obj );
while (val == (Obj) 0) {
val = ErrorReturnObj("Method for an attribute must return a value",
0L, 0L,
"you can supply a value <val> via 'return <val>;'");
}
val = CopyObj( val, 0 );

/* set the value (but not for internal objects) */
Expand Down Expand Up @@ -2983,12 +2988,12 @@ Obj DoProperty (
/* call the operation to compute the value */
val = DoOperation1Args( self, obj );
while ( val != True && val != False ) {
val = ErrorReturnObj(
val = ErrorReturnObj(
"Method for a property did not return true or false",
0L, 0L,
0L, 0L,
"you can 'return true;' or 'return false;'");
}

/* set the value (but not for internal objects) */
if ( ENABLED_ATTR(self) == 1 && ! IS_MUTABLE_OBJ(obj) ) {
switch ( TNUM_OBJ( obj ) ) {
Expand Down Expand Up @@ -3038,7 +3043,13 @@ Obj DoVerboseProperty (

/* call the operation to compute the value */
val = DoVerboseOperation1Args( self, obj );

while ( val != True && val != False ) {
val = ErrorReturnObj(
"Method for a property did not return true or false",
0L, 0L,
"you can 'return true;' or 'return false;'");
}

/* set the value (but not for internal objects) */
if ( ENABLED_ATTR(self) == 1 && ! IS_MUTABLE_OBJ(obj) ) {
switch ( TNUM_OBJ( obj ) ) {
Expand Down

0 comments on commit 29beb57

Please sign in to comment.