}
/* Things we have to clean up */
- free(smbc_getWorkgroup(context));
smbc_setWorkgroup(context, NULL);
-
- free(smbc_getNetbiosName(context));
smbc_setNetbiosName(context, NULL);
-
- free(smbc_getUser(context));
smbc_setUser(context, NULL);
DEBUG(3, ("Context %p successfully freed\n", context));
smbc_init_context(SMBCCTX *context)
{
int pid;
- char *user = NULL;
char *home = NULL;
if (!context) {
/*
* FIXME: Is this the best way to get the user info?
*/
- user = getenv("USER");
+ char *user = getenv("USER");
/* walk around as "guest" if no username can be found */
if (!user) {
user = SMB_STRDUP("guest");
}
smbc_setUser(context, user);
+ SAFE_FREE(user);
+
+ if (!smbc_getUser(context)) {
+ errno = ENOMEM;
+ return NULL;
+ }
}
if (!smbc_getNetbiosName(context)) {
}
smbc_setNetbiosName(context, netbios_name);
+ SAFE_FREE(netbios_name);
+
+ if (!smbc_getNetbiosName(context)) {
+ errno = ENOMEM;
+ return NULL;
+ }
}
DEBUG(1, ("Using netbios name %s.\n", smbc_getNetbiosName(context)));
}
smbc_setWorkgroup(context, workgroup);
+ SAFE_FREE(workgroup);
+
+ if (!smbc_getWorkgroup(context)) {
+ errno = ENOMEM;
+ return NULL;
+ }
}
DEBUG(1, ("Using workgroup %s.\n", smbc_getWorkgroup(context)));