Skip to content

Commit ae112fe

Browse files
committed
Merge branch 'sticker_errors' of https://github.com/jcorporation/MPD
2 parents a1cbfa1 + bd36b5e commit ae112fe

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

src/command/StickerCommands.cxx

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "Instance.hxx"
1818
#include "util/StringAPI.hxx"
1919
#include "util/ScopeExit.hxx"
20+
#include "util/StringCompare.hxx"
2021
#include "tag/Settings.hxx"
2122
#include "tag/ParseName.hxx"
2223
#include "tag/Names.hxx"
@@ -456,16 +457,31 @@ handle_sticker(Client &client, Request args, Response &r)
456457
return handler->List(uri);
457458

458459
/* set */
459-
if (args.size() == 5 && StringIsEqual(cmd, "set"))
460+
if (args.size() == 5 && StringIsEqual(cmd, "set")) {
461+
if (StringIsEmpty(sticker_name)) {
462+
r.FmtError(ACK_ERROR_ARG, "empty sticker name");
463+
return CommandResult::ERROR;
464+
}
460465
return handler->Set(uri, sticker_name, args[4]);
466+
}
461467

462468
/* inc */
463-
if (args.size() == 5 && StringIsEqual(cmd, "inc"))
469+
if (args.size() == 5 && StringIsEqual(cmd, "inc")) {
470+
if (StringIsEmpty(sticker_name)) {
471+
r.FmtError(ACK_ERROR_ARG, "empty sticker name");
472+
return CommandResult::ERROR;
473+
}
464474
return handler->Inc(uri, sticker_name, args[4]);
475+
}
465476

466477
/* dec */
467-
if (args.size() == 5 && StringIsEqual(cmd, "dec"))
478+
if (args.size() == 5 && StringIsEqual(cmd, "dec")) {
479+
if (StringIsEmpty(sticker_name)) {
480+
r.FmtError(ACK_ERROR_ARG, "empty sticker name");
481+
return CommandResult::ERROR;
482+
}
468483
return handler->Dec(uri, sticker_name, args[4]);
484+
}
469485

470486
/* delete */
471487
if ((args.size() == 3 || args.size() == 4) && StringIsEqual(cmd, "delete"))

src/sticker/Database.cxx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,9 @@ StickerDatabase::StoreValue(const char *type, const char *uri,
233233
assert(type != nullptr);
234234
assert(uri != nullptr);
235235
assert(name != nullptr);
236+
assert(*name != 0);
236237
assert(value != nullptr);
237238

238-
if (StringIsEmpty(name))
239-
return;
240-
241239
sqlite3_stmt *const s = stmt[STICKER_SQL_SET];
242240

243241
BindAll(s, type, uri, name, value, value);
@@ -326,6 +324,7 @@ StickerDatabase::DeleteValue(const char *type, const char *uri,
326324

327325
assert(type != nullptr);
328326
assert(uri != nullptr);
327+
assert(name != nullptr);
329328

330329
BindAll(s, type, uri, name);
331330

0 commit comments

Comments
 (0)