- pctx->file = stream;
- if (*package && single) {
- pctx->package = *package;
- pctx->merge = true;
- }
-
- /*
- * If 'name' was supplied, assume that the supplied stream does not contain
- * the appropriate 'package <name>' string to specify the config name
- * NB: the config file can still override the package name
- */
- if (name) {
- UCI_ASSERT(ctx, uci_validate_package(name));
- pctx->name = name;
- }
+ if (pctx != NULL) {
+ pctx->file = stream;
+ if (*package && single) {
+ pctx->package = *package;
+ pctx->merge = true;
+ }
+ /*
+ * If 'name' was supplied, assume that the supplied stream does not contain
+ * the appropriate 'package <name>' string to specify the config name
+ * NB: the config file can still override the package name
+ */
+ if (name) {
+ UCI_ASSERT(ctx, uci_validate_package(name));
+ pctx->name = name;
+ }