Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions release_build_files/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,8 @@ code.
- General (Desktop): Fixed Auth and App Check staying registered with their
`App` after being deleted. Previously a deleted `AppCheck` instance could
be silently re-created by other products using the same `App`.
- Storage (Desktop): Fixed a crash when destroying a `Listener` that was
never passed to a storage operation.

### 14.2.0
- Changes
Expand Down
5 changes: 4 additions & 1 deletion storage/src/desktop/listener_desktop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ namespace storage {
namespace internal {

ListenerInternal::ListenerInternal(Listener *listener)
: listener_(listener), bytes_transferred_(-1), total_byte_count_(-1) {}
: listener_(listener),
rest_operation_(nullptr),
bytes_transferred_(-1),
total_byte_count_(-1) {}

ListenerInternal::~ListenerInternal() {
MutexLock lock(mutex_);
Expand Down
8 changes: 8 additions & 0 deletions storage/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,11 @@ firebase_cpp_cc_test(
firebase_testing
)

firebase_cpp_cc_test(
firebase_storage_desktop_listener_test
SOURCES
desktop/listener_desktop_test.cc
DEPENDS
firebase_rest_lib
firebase_storage
)
39 changes: 39 additions & 0 deletions storage/tests/desktop/listener_desktop_test.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "storage/src/desktop/listener_desktop.h"

#include <cstring>
#include <new>

#include "gtest/gtest.h"

namespace {

using firebase::storage::internal::ListenerInternal;

// Regression test for https://github.com/firebase/firebase-cpp-sdk/issues/1966.
// A listener that was never attached to an operation must not touch a rest
// operation when it is destroyed. The object is constructed in pre-filled
// storage so that any member the constructor leaves uninitialized holds a
// non-null garbage value.
TEST(ListenerDesktopTest, DestroyWithoutAttachedOperation) {
alignas(ListenerInternal) unsigned char storage[sizeof(ListenerInternal)];
std::memset(storage, 0xAB, sizeof(storage));

ListenerInternal* listener = new (storage) ListenerInternal(nullptr);
listener->~ListenerInternal();
}

} // namespace
Loading