Skip to content

Commit

Permalink
Fix null pointer exception for external client.
Browse files Browse the repository at this point in the history
  • Loading branch information
mobizt committed Sep 12, 2023
1 parent 0972637 commit 504a97e
Show file tree
Hide file tree
Showing 42 changed files with 68 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ void networkConnection()
void networkStatusRequestCallback()
{
// Set the network status based on your network client
fbdo.setNetworkStatus(true /* or false */);
stream.setNetworkStatus(true /* or false */);
fbdo.setNetworkStatus(false /* or true */);
stream.setNetworkStatus(false /* or true */);
}

void streamCallback(FirebaseStream data)
Expand Down
4 changes: 2 additions & 2 deletions library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Firebase Arduino Client Library",
"version": "4.4.3",
"name": "Firebase Arduino Client Library for ESP8266 and ESP32",
"version": "4.4.4",
"keywords": "communication, REST, esp32, esp8266, arduino",
"description": "The library supports Firebase products e.g. Realtime database, Cloud Firestore database, Firebase Storage and Google Cloud Storage, Cloud Functions for Firebase and Cloud Messaging. The library also supported other Arduino devices using Clients interfaces e.g. WiFiClient, EthernetClient, and GSMClient.",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name=Firebase Arduino Client Library for ESP8266 and ESP32

version=4.4.3
version=4.4.4

author=Mobizt

Expand Down
2 changes: 1 addition & 1 deletion src/FB_Const.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/FB_Error.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/FB_Network.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/FB_Utils.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/Firebase.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/Firebase.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/FirebaseFS.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

Expand Down
22 changes: 14 additions & 8 deletions src/core/FirebaseCore.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

/**
* Google's Firebase Token Management class, FirebaseCore.cpp version 1.0.0
* Google's Firebase Token Management class, FirebaseCore.cpp version 1.0.1
*
* Created September 5, 2023
* Created September 12, 2023
*
* The MIT License (MIT)
* Copyright (c) 2023 K. Suwatchai (Mobizt)
Expand Down Expand Up @@ -939,9 +939,15 @@ void FirebaseCore::freeClient(Firebase_TCP_Client **client)
_password = (*client)->_password;
#endif
}
delete *client;

// Only internal client can be deleted
if (_cli_type == firebase_client_type_internal_basic_client)
delete *client;
}
*client = nullptr;

// Reset pointer in case internal client
if (_cli_type == firebase_client_type_internal_basic_client)
*client = nullptr;
}

void FirebaseCore::setTokenError(int code)
Expand Down Expand Up @@ -1708,12 +1714,12 @@ bool FirebaseCore::reconnect()
// otherwise the networkStatus will not update
// and network cannot resume.

if (noClient)
if (noClient)
newClient(&tcpClient);

reconnect(tcpClient, nullptr);
reconnect(tcpClient, nullptr);

if (noClient)
if (noClient)
freeClient(&tcpClient);

networkChecking = false;
Expand Down
6 changes: 3 additions & 3 deletions src/core/FirebaseCore.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

/**
* Google's Firebase Token Management class, FirebaseCore.h version 1.0.0
* Google's Firebase Token Management class, FirebaseCore.h version 1.0.1
*
* Created September 5, 2023
* Created September 12, 2023
*
* The MIT License (MIT)
* Copyright (c) 2023 K. Suwatchai (Mobizt)
Expand Down
4 changes: 2 additions & 2 deletions src/core/Firebase_Client_Version.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef FIREBASE_CLIENT_VERSION
#define FIREBASE_CLIENT_VERSION "4.4.3"
#define FIREBASE_CLIENT_VERSION_NUM 40403
#define FIREBASE_CLIENT_VERSION "4.4.4"
#define FIREBASE_CLIENT_VERSION_NUM 40404

/* The inconsistent file version checking to prevent mixed versions compilation. */
#define FIREBASE_CLIENT_VERSION_CHECK(ver) (ver == FIREBASE_CLIENT_VERSION_NUM)
Expand Down
2 changes: 1 addition & 1 deletion src/firestore/FB_Firestore.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/firestore/FB_Firestore.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/functions/FB_Functions.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/functions/FB_Functions.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/functions/FunctionsConfig.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/functions/FunctionsConfig.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/functions/PocicyBuilder.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/functions/PolicyBuilder.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/gcs/GCS.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/gcs/GCS.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/message/FCM.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/message/FCM.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/message/LFCM.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/rtdb/FB_RTDB.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/rtdb/FB_RTDB.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/rtdb/QueryFilter.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/rtdb/QueryFilter.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/rtdb/QueueInfo.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/rtdb/QueueInfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/rtdb/QueueManager.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/rtdb/QueueManager.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/rtdb/stream/FB_MP_Stream.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/rtdb/stream/FB_MP_Stream.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/rtdb/stream/FB_Stream.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/rtdb/stream/FB_Stream.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

Expand Down
15 changes: 7 additions & 8 deletions src/session/FB_Session.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

/**
* Google's Firebase Data class, FB_Session.cpp version 1.4.0
* Google's Firebase Data class, FB_Session.cpp version 1.4.1
*
* Created September 5, 2023
* Created September 12, 2023
*
* The MIT License (MIT)
* Copyright (c) 2023 K. Suwatchai (Mobizt)
Expand Down Expand Up @@ -74,14 +74,13 @@ FirebaseData::~FirebaseData()
void FirebaseData::setGenericClient(Client *client, FB_NetworkConnectionRequestCallback networkConnectionCB,
FB_NetworkStatusRequestCallback networkStatusCB)
{
if (client)
if (client && networkConnectionCB && networkStatusCB)
{
_client = client;
Core.setTCPClient(&tcpClient);
tcpClient.setClient(_client, networkConnectionCB, networkStatusCB);
}

if (_networkConnectionCB && _networkStatusCB)
tcpClient.setClient(_client, _networkConnectionCB, _networkStatusCB);
// Client type shall be set before calling this.
Core.setTCPClient(&tcpClient);
}

void FirebaseData::setGSMClient(Client *client, void *modem, const char *pin, const char *apn, const char *user, const char *password)
Expand Down
6 changes: 3 additions & 3 deletions src/session/FB_Session.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

/**
* Google's Firebase Data class, FB_Session.h version 1.4.0
* Google's Firebase Data class, FB_Session.h version 1.4.1
*
* Created September 5, 2023
* Created September 12, 2023
*
* The MIT License (MIT)
* Copyright (c) 2023 K. Suwatchai (Mobizt)
Expand Down
2 changes: 1 addition & 1 deletion src/storage/FCS.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/storage/FCS.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40403)
#if !FIREBASE_CLIENT_VERSION_CHECK(40404)
#error "Mixed versions compilation."
#endif

Expand Down

0 comments on commit 504a97e

Please sign in to comment.