[Vm-dev] VM Maker Inbox: VMMaker.oscog-eem.2537.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Jul 24 20:01:50 UTC 2019


Eliot Miranda uploaded a new version of VMMaker to project VM Maker Inbox:
http://source.squeak.org/VMMakerInbox/VMMaker.oscog-eem.2537.mcz

==================== Summary ====================

Name: VMMaker.oscog-eem.2537
Author: eem
Time: 24 July 2019, 1:01:33.831274 pm
UUID: 0518f049-7c3c-4dfa-8e2d-04e2cf2eee40
Ancestors: VMMaker.oscog-eem.2536

Bite the bulklet and embrace methodReturnString:.
Better this is well implemented once in the interpreter than potentially badly implemented many times in plugins.  Check the C string argument for null to avoid passing null to strlen:, which can crash.

=============== Diff against VMMaker.oscog-eem.2536 ===============

Item was changed:
  ----- Method: InterpreterProxy>>methodReturnString: (in category 'stack access') -----
  methodReturnString: aCString
+ 	"Attempt to answer a ByteString for a given C string as the result of a primitive."
- 	"Sets the return value for a method."
- 	"THIS IS DUBIOUS!!  CONSIDER REMOVING IT!!  RIGHT NOW IT IS NOT SENT."
  	<var: 'aCString' type: #'char *'>
+ 	aCString
+ 		ifNil: [primFailCode := PrimErrOperationFailed]
+ 		ifNotNil:
+ 			[(self stringForCString: aCString)
+ 				ifNil: [primFailCode := PrimErrNoMemory]
+ 				ifNotNil: [:result| self pop: argumentCount+1 thenPush: result]].
- 	(self stringForCString: aCString)
- 		ifNil: [primFailCode := PrimErrNoMemory]
- 		ifNotNil: [:result| self pop: argumentCount+1 thenPush: result].
  	^0!

Item was changed:
  ----- Method: StackInterpreter>>methodReturnString: (in category 'plugin primitive support') -----
  methodReturnString: aCString
+ 	"Attempt to answer a ByteString for a given C string as the result of a primitive."
- 	"Sets the return value for a method."
  	<var: 'aCString' type: #'char *'>
+ 	aCString
+ 		ifNil: [primFailCode := PrimErrOperationFailed]
+ 		ifNotNil:
+ 			[(self stringForCString: aCString)
+ 				ifNil: [primFailCode := PrimErrNoMemory]
+ 				ifNotNil: [:result| self pop: argumentCount+1 thenPush: result]].
- 	self pop: argumentCount+1 thenPush: (objectMemory stringForCString: aCString).
  	^0!



More information about the Vm-dev mailing list