s4:samba: Do not segfault if we run into issues
[garming/samba-autobuild/.git] / source4 / smbd / server.c
index eef0f7bf3d20a5425e50f604d64000b9b938bb8f..f107350e1af09c01edc1e47008d1ab59b87173d3 100644 (file)
@@ -105,8 +105,16 @@ static void cleanup_tmp_files(struct loadparm_context *lp_ctx)
 {
        char *path;
        TALLOC_CTX *mem_ctx = talloc_new(NULL);
+       if (mem_ctx == NULL) {
+               exit_daemon("Failed to create memory context",
+                           ENOMEM);
+       }
 
        path = smbd_tmp_path(mem_ctx, lp_ctx, NULL);
+       if (path == NULL) {
+               exit_daemon("Failed to cleanup temporary files",
+                           EINVAL);
+       }
 
        recursive_delete(path);
        talloc_free(mem_ctx);