diff --git a/sortix/device.cpp b/sortix/device.cpp index 6f9fb277..65b0961b 100644 --- a/sortix/device.cpp +++ b/sortix/device.cpp @@ -40,7 +40,7 @@ namespace Sortix void Device::Unref() { - if ( --refcount == 0 ) { delete this; } + if ( --refcount == 0 || refcount == SIZE_MAX ) { delete this; } } void Device::Refer()