Skip to content

Commit

Permalink
Fix param shift issue in singleton()
Browse files Browse the repository at this point in the history
  • Loading branch information
stevieb9 committed Sep 12, 2022
1 parent 3c20d46 commit a8bd1e2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Changes
@@ -1,7 +1,9 @@
Revision history for Perl extension IPC::Shareable.

1.13 UNREL
-
- In singleton(), do a check whether class was sent in. There was a shifting
issue if called with IPC::Shareable::singleton() as opposed to
IPC::Shareable->singleton()

1.12 2022-03-13
- Add tests in t/07-new.t to test how using tied() against a dereferenced
Expand Down
9 changes: 9 additions & 0 deletions lib/IPC/Shareable.pm
Expand Up @@ -553,6 +553,15 @@ sub sem {
return $knot->{_sem} if defined $knot->{_sem};
}
sub singleton {

# If called with IPC::Shareable::singleton() as opposed to
# IPC::Shareable->singleton(), the class isn't sent in. Check
# for this and fix it if necessary

if (! defined $_[0] || $_[0] ne __PACKAGE__) {
unshift @_, __PACKAGE__;
}

my ($class, $glue, $warn) = @_;

if (! defined $glue) {
Expand Down

0 comments on commit a8bd1e2

Please sign in to comment.