for (i = 0; i < message->n_unix_fds; ++i) {
ret->unix_fds[i] = _dbus_dup(message->unix_fds[i], NULL);
- if (ret->unix_fds[i] < 0)
+ if (ret->unix_fds[i] < 0) {
+ ret->n_unix_fds = i;
goto err;
+ }
}
ret->n_unix_fds = message->n_unix_fds;
_dbus_string_free (&ret->body);
#ifdef HAVE_UNIX_FD_PASSING
- close_unix_fds(ret->unix_fds, &ret->n_unix_fds);
- dbus_free(ret->unix_fds);
+ if (ret->unix_fds)
+ {
+ close_unix_fds(ret->unix_fds, &ret->n_unix_fds);
+ dbus_free(ret->unix_fds);
+ }
#endif
return NULL;