Skip to content

Commit

Permalink
lib: coerce -0 into 0 for process APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
HarshithaKP committed Apr 14, 2020
1 parent 8d93df4 commit c2dfd02
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/internal/bootstrap/switches/does_own_process_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ function wrapPosixCredentialSetters(credentials) {
function wrapIdSetter(type, method) {
return function(id) {
validateId(id, 'id');
// Coerce -0 into 0, because that is the most reasonable thing
// for system calls
if (id === -0) id = 0;
// Result is 0 on success, 1 if credential is unknown.
const result = method(id);
if (result === 1) {
Expand Down

0 comments on commit c2dfd02

Please sign in to comment.