Commit 7781092
fix(commands): do not throw on a commandPresets.json that is not an object
jsoncpp throws Json::LogicError from Json::Value::isMember() on a value
that is neither an object nor null, and nothing in fppd catches it, so a
commandPresets.json holding an array (or a scalar) took the daemon down
with SIGABRT - at startup inside LoadPresets(), and again on every
FileMonitor reload of that file, i.e. a boot loop.
Master is covered by LoadJsonFromFile(..., JsonRoot::Object) from the
config-root-shape sweep; that sweep does not exist on this branch, so
guard the reads instead. All three readers of this file get the same
isObject() test, not just the reported one - the two in the
/api/commandPresets handler read the same file and would abort the
daemon the moment the presets page was opened.
Behaviour for a well-formed file is unchanged: isObject() is true for
it, and a missing file still yields a null root that isMember() already
returned false for.
Verified against the real libjsoncpp by running this exact expression
over each root shape a config file can hold. The control dies first: an
array root gives "in Json::Value::find(begin, end): requires objectValue
or nullValue" as an uncaught throw, which is this bucket's stack and
signal exactly. With the guard, every shape - object, empty array, array
of objects, null and a bare scalar - returns cleanly and the valid
object still resolves. The translation unit compiles on this branch.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent ca97190 commit 7781092
1 file changed
Lines changed: 9 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
363 | | - | |
| 363 | + | |
364 | 364 | | |
365 | 365 | | |
366 | 366 | | |
| |||
372 | 372 | | |
373 | 373 | | |
374 | 374 | | |
375 | | - | |
| 375 | + | |
376 | 376 | | |
377 | 377 | | |
378 | 378 | | |
| |||
633 | 633 | | |
634 | 634 | | |
635 | 635 | | |
636 | | - | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
637 | 643 | | |
638 | 644 | | |
639 | 645 | | |
| |||
0 commit comments