From e9e214bb83cc939f24a16c3219a427f5e730f936 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Mon, 8 Sep 2014 16:37:59 -0500
Subject: [PATCH] oops: Fix crash creating canned responses

---
 scp/canned.php | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scp/canned.php b/scp/canned.php
index 4a5447525..a600cee5a 100644
--- a/scp/canned.php
+++ b/scp/canned.php
@@ -85,11 +85,11 @@ if($_POST && $thisstaff->canManageCannedResponses()) {
                 $_REQUEST['a']=null;
                 //Upload attachments
                 $keepers = $canned_form->getField('attachments')->getClean();
-                if ($keepers && ($c=Canned::lookup($id)))
+                if (($c=Canned::lookup($id)) && $keepers)
                     $c->attachments->upload($keepers);
 
                 // Attach inline attachments from the editor
-                if (isset($_POST['draft_id'])
+                if ($c && isset($_POST['draft_id'])
                         && ($draft = Draft::lookup($_POST['draft_id'])))
                     $c->attachments->upload(
                         $draft->getAttachmentIds($_POST['response']), true);
-- 
GitLab