From 0be77c3ae471f3bed5215b84d7e1d702f2ec1696 Mon Sep 17 00:00:00 2001
From: Subv <subv2112@gmail.com>
Date: Mon, 9 Jan 2017 13:02:44 -0500
Subject: [PATCH] Timers: Return an error when calling SetTimer with negative
 timeouts.

---
 src/core/hle/svc.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index 96db39ad94..1baa80671b 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -837,6 +837,11 @@ static ResultCode SetTimer(Kernel::Handle handle, s64 initial, s64 interval) {
 
     LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle);
 
+    if (initial < 0 || interval < 0) {
+        return ResultCode(ErrorDescription::OutOfRange, ErrorModule::Kernel,
+                          ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
+    }
+
     SharedPtr<Timer> timer = Kernel::g_handle_table.Get<Timer>(handle);
     if (timer == nullptr)
         return ERR_INVALID_HANDLE;