Skip to content

Commit 2ee1691

Browse files
Fix crashes caused by providing empty or invalid parameters to chat functions. (#35)
fix(crash): fix crashes when empty or invalid parameter were passed to functions. Fix crashes that could happen when empty or invalid parameters were passed to some functions. Add needed guard checks and print to log in case of incorrect input. fix(log): fix false warnings from C-Core. Remove false warnings that were printed from C-Core. fix(fab): adjust small changes required by FAB. Adjust Copyrights in files and FabUrl to fix issues reported by FAB.
1 parent 022d712 commit 2ee1691

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+4672
-4357
lines changed

.github/workflows/release/versions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
".pubnub.yml": [
3-
{ "pattern": "^version: \"v(.+)\"$", "cleared": true },
3+
{ "pattern": "^version: (.+)$", "cleared": false },
44
{ "pattern": "\/releases\/tag\/v([0-9]+\\.[0-9]+\\.[0-9]+(\\.[0-9]+)?)", "cleared": true }
55
],
66
"PubnubChat.uplugin": [

.pubnub.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
name: unreal-engine-chat
2-
version: v0.4.2
2+
version: v0.4.3
33
schema: 1
44
scm: github.com/pubnub/unreal-engine-chat
55
changelog:
6+
- date: 2025-07-08
7+
version: v0.4.3
8+
changes:
9+
- type: bug
10+
text: "Fix crashes that could happen when empty or invalid parameters were passed to some functions. Add needed guard checks and print to log in case of incorrect input."
11+
- type: bug
12+
text: "Remove false warnings that were printed from C-Core."
13+
- type: bug
14+
text: "Adjust Copyrights in files and FabUrl to fix issues reported by FAB."
615
- date: 2025-06-16
716
version: v0.4.2
817
changes:

PubnubChat.uplugin

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"FileVersion": 3,
3-
"Version": 18,
4-
"VersionName": "0.4.2",
3+
"Version": 19,
4+
"VersionName": "0.4.3",
55
"FriendlyName": "Pubnub Chat SDK",
66
"Description": "Quickly and easily integrate a real-time text chat solution that is reliable, flexible, and scalable.",
77
"Category": "Code",
88
"CreatedBy": "PubNub Inc.",
99
"CreatedByURL": "https://www.pubnub.com/",
10-
"DocsURL": "https://www.pubnub.com/docs/chat/unreal-chat-sdk/overview",
11-
"FabURL": "com.epicgames.launcher://ue/Fab/product/81b7deb9-82ad-41c8-b123-decccfb32fd8",
10+
"DocsURL": "https://www.pubnub.com/docs/chat/unreal-chat-sdk/build/configuration",
11+
"FabURL": "com.epicgames.launcher://ue/Fab/product/69e7b3b4-6ef4-4c1c-b84a-0029c8ae63ae",
1212
"SupportURL": "",
1313
"CanContainContent": true,
1414
"IsBetaVersion": false,

Source/PubnubChatSDK/Private/FunctionLibraries/PubnubChatUtilities.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 PubNub Inc. All Rights Reserved.
1+
// Copyright 2025 PubNub Inc. All Rights Reserved.
22

33

44
#include "FunctionLibraries/PubnubChatUtilities.h"
@@ -123,11 +123,11 @@ TArray<FPubnubMessageAction> UPubnubChatUtilities::CppMessageActionsToUnrealMess
123123

124124
Pubnub::Vector<Pubnub::Channel> UPubnubChatUtilities::UnrealChannelsToCppChannels(TArray<UPubnubChannel*> &PubnubChannels)
125125
{
126-
//Pubnub::Vector<Pubnub::Channel> CppChannels;
127126
std::vector<Pubnub::Channel> CppChannels;
128127

129128
for(auto &PubnubChannel : PubnubChannels)
130129
{
130+
if(nullptr == PubnubChannel) {continue;}
131131
CppChannels.push_back(*PubnubChannel->GetInternalChannel());
132132
}
133133
return Pubnub::Vector<Pubnub::Channel>(std::move(CppChannels));
@@ -139,6 +139,7 @@ Pubnub::Vector<Pubnub::User> UPubnubChatUtilities::UnrealUsersToCppUsers(TArray<
139139

140140
for(auto &PubnubUser : PubnubUsers)
141141
{
142+
if(nullptr == PubnubUser) {continue;}
142143
CppUsers.push_back(*PubnubUser->GetInternalUser());
143144
}
144145
return CppUsers;
@@ -150,6 +151,7 @@ Pubnub::Vector<Pubnub::Message> UPubnubChatUtilities::UnrealMessagesToCppMessage
150151

151152
for(auto &PubnubMessage : PubnubMessages)
152153
{
154+
if(nullptr == PubnubMessage) {continue;}
153155
CppMessages.push_back(*PubnubMessage->GetInternalMessage());
154156
}
155157
return CppMessages;
@@ -161,6 +163,7 @@ Pubnub::Vector<Pubnub::ThreadMessage> UPubnubChatUtilities::UnrealThreadMessages
161163

162164
for(auto &PubnubMessage : PubnubThreadMessages)
163165
{
166+
if(nullptr == PubnubMessage) {continue;}
164167
CppMessages.push_back(*PubnubMessage->GetInternalThreadMessage());
165168
}
166169
return CppMessages;
@@ -172,6 +175,7 @@ Pubnub::Vector<Pubnub::Membership> UPubnubChatUtilities::UnrealMembershipsToCppM
172175

173176
for(auto &PubnubMembership : PubnubMemberships)
174177
{
178+
if(nullptr == PubnubMembership) {continue;}
175179
CppMemberships.push_back(*PubnubMembership->GetInternalMembership());
176180
}
177181
return CppMemberships;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright 2024 PubNub Inc. All Rights Reserved.
2+
3+
4+
#include "FunctionLibraries/PubnubLogUtilities.h"
5+
#include "PubnubChatSubsystem.h"
6+
7+
FString UPubnubLogUtilities::GetNameFromFunctionMacro(FString FunctionName)
8+
{
9+
if(FunctionName.IsEmpty()) {return "";}
10+
int Index = -1;
11+
FunctionName.FindLastChar(TEXT(':'), Index);
12+
return FunctionName.Mid(Index + 1);
13+
}
14+
15+
void UPubnubLogUtilities::PrintEmptyFieldLog(FString FunctionName, FString FieldName)
16+
{
17+
UE_LOG(PubnubChatLog, Warning, TEXT("Failed to: %s, %s field can't be empty."), *GetNameFromFunctionMacro(FunctionName), *FieldName);
18+
}
19+
20+
void UPubnubLogUtilities::PrintInvalidObjectFieldLog(FString FunctionName, FString FieldName)
21+
{
22+
UE_LOG(PubnubChatLog, Warning, TEXT("Failed to: %s, %s has to be a valid object."), *GetNameFromFunctionMacro(FunctionName), *FieldName);
23+
}
24+
25+
void UPubnubLogUtilities::PrintEmptyArrayFieldLog(FString FunctionName, FString FieldName)
26+
{
27+
UE_LOG(PubnubChatLog, Warning, TEXT("Failed to: %s, %s has to contain at least one valid object."), *GetNameFromFunctionMacro(FunctionName), *FieldName);
28+
}
29+
30+
void UPubnubLogUtilities::PrintFunctionError(FString FunctionName, FString Error)
31+
{
32+
UE_LOG(PubnubChatLog, Error, TEXT("Failed to: %s, Error: %s."), *GetNameFromFunctionMacro(FunctionName), *Error);
33+
}

Source/PubnubChatSDK/Private/PubnubAccessManager.cpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
// Copyright 2024 PubNub Inc. All Rights Reserved.
1+
// Copyright 2025 PubNub Inc. All Rights Reserved.
22

33

44
#include "PubnubAccessManager.h"
5+
#include "PubnubChatSubsystem.h"
6+
#include "PubnubMacroUtilities.h"
57
#include "FunctionLibraries/PubnubChatUtilities.h"
8+
#include "FunctionLibraries/PubnubLogUtilities.h"
69

710
UPubnubAccessManager* UPubnubAccessManager::Create(Pubnub::AccessManager AccessManager)
811
{
@@ -19,20 +22,44 @@ UPubnubAccessManager::~UPubnubAccessManager()
1922

2023
bool UPubnubAccessManager::CanI(EPubnubAccessManagerPermission Permission, EPubnubAccessManagerResourceType ResourceType, FString ResourceName)
2124
{
25+
if(!IsInternalAccessManagerValid()) {return false;}
26+
2227
return InternalAccessManager->can_i((Pubnub::AccessManager::Permission)(uint8)Permission, (Pubnub::AccessManager::ResourceType)(uint8)ResourceType, UPubnubChatUtilities::FStringToPubnubString(ResourceName));
2328
}
2429

2530
FString UPubnubAccessManager::ParseToken(FString Token)
2631
{
32+
if(!IsInternalAccessManagerValid()) {return "";}
33+
34+
PUBNUB_RETURN_IF_EMPTY(Token, "");
35+
2736
return UPubnubChatUtilities::PubnubStringToFString(InternalAccessManager->parse_token(UPubnubChatUtilities::FStringToPubnubString(Token)));
2837
}
2938

3039
void UPubnubAccessManager::SetAuthToken(FString Token)
3140
{
41+
if(!IsInternalAccessManagerValid()) {return;}
42+
43+
PUBNUB_RETURN_IF_EMPTY(Token);
44+
3245
InternalAccessManager->set_auth_token(UPubnubChatUtilities::FStringToPubnubString(Token));
3346
}
3447

3548
int UPubnubAccessManager::SetPubnubOrigin(FString Origin)
3649
{
50+
if(!IsInternalAccessManagerValid()) {return -1;}
51+
52+
PUBNUB_RETURN_IF_EMPTY(Origin, -1);
53+
3754
return InternalAccessManager->set_pubnub_origin(UPubnubChatUtilities::FStringToPubnubString(Origin));
55+
}
56+
57+
bool UPubnubAccessManager::IsInternalAccessManagerValid()
58+
{
59+
if(InternalAccessManager == nullptr)
60+
{
61+
UE_LOG(PubnubChatLog, Error, TEXT("This Access Manager is invalid"));
62+
return false;
63+
}
64+
return true;
3865
}

Source/PubnubChatSDK/Private/PubnubCallbackStop.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 PubNub Inc. All Rights Reserved.
1+
// Copyright 2025 PubNub Inc. All Rights Reserved.
22

33

44
#include "PubnubCallbackStop.h"

0 commit comments

Comments
 (0)