for (index = moduleSpecList; index && *index; index++) { SECMODModule *child; child = SECMOD_LoadModule(*index,module,PR_TRUE); if (!child) break; if (child->isCritical && !child->loaded) { rv = SECFailure;
for (index = moduleSpecList; *index; index++) { SECMODModule *child; child = SECMOD_LoadModule(*index,module,PR_TRUE); if (!child) break; if (child->isCritical && !child->loaded) { int err = PORT_GetError(); if (!err) err = SEC_ERROR_NO_MODULE; SECMOD_DestroyModule(child); PORT_SetError(err); rv = SECFailure; break; }
SECMOD_LoadModule(char *modulespec,SECMODModule *parent, PRBool recurse){    char *library = NULL, *moduleName = NULL, *parameters = NULL, *nss= NULL;    SECStatus status;    SECMODModule *module = NULL;    SECStatus rv;    /* initialize the underlying module structures */    SECMOD_Init();    status = pk11_argParseModuleSpec(modulespec, &library, &moduleName, 							&parameters, &nss);    if (status != SECSuccess) {	goto loser;    }    module = SECMOD_CreateModule(library, moduleName, parameters, nss);    if (library) PORT_Free(library);    if (moduleName) PORT_Free(moduleName);    if (parameters) PORT_Free(parameters);    if (nss) PORT_Free(nss);    if (!module) {	goto loser;    }    if (parent) {    	module->parent = SECMOD_ReferenceModule(parent);    }    /* load it */    rv = SECMOD_LoadPKCS11Module(module);    if (rv != SECSuccess) {	goto loser;    }    if (recurse && module->isModuleDB) {	char ** moduleSpecList;	char **index;	moduleSpecList = SECMOD_GetModuleSpecList(module);	for (index = moduleSpecList; index && *index; index++) {	    SECMODModule *child;	    child = SECMOD_LoadModule(*index,module,PR_TRUE);	    if (!child) break;	    if (child->isCritical && !child->loaded) {		rv = SECFailure;		SECMOD_DestroyModule(child);		break;	    }	    SECMOD_DestroyModule(child);	}	SECMOD_FreeModuleSpecList(module,moduleSpecList);    }    if (rv != SECSuccess) {	goto loser;    }    /* inherit the reference */    if (!module->moduleDBOnly) {	SECMOD_AddModuleToList(module);    } else {	SECMOD_AddModuleToDBOnlyList(module);    }       /* handle any additional work here */    return module;loser:    if (module) {	if (module->loaded) {	    SECMOD_UnloadModule(module);	}	SECMOD_AddModuleToUnloadList(module);    }    return module;}