mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 01:50:38 +00:00
Fix valgrind issues found running unit tests
* GLContextTLSData default constructor should be initialised. * Add some missing deletes in shader reflection * Call freeaddrinfo after getaddrinfo * Don't leak if we're reserving 0 bytes in rdcstr over the top of an already empty rdcstr
This commit is contained in:
@@ -327,7 +327,7 @@ public:
|
||||
{
|
||||
// if we're empty then normally reserving s==0 would do nothing, but if we need to append a null
|
||||
// terminator then we do actually need to allocate
|
||||
if(s == 0 && capacity() == 0 && null_terminator<T>::allocCount(0) > 0)
|
||||
if(s == 0 && capacity() == 0 && elems == NULL && null_terminator<T>::allocCount(0) > 0)
|
||||
{
|
||||
elems = allocate(null_terminator<T>::allocCount(0));
|
||||
return;
|
||||
|
||||
@@ -312,7 +312,7 @@ private:
|
||||
|
||||
struct GLContextTLSData
|
||||
{
|
||||
GLContextTLSData() {}
|
||||
GLContextTLSData() : ctxPair({NULL, NULL}), ctxRecord(NULL) {}
|
||||
GLContextTLSData(ContextPair p, GLResourceRecord *r) : ctxPair(p), ctxRecord(r) {}
|
||||
ContextPair ctxPair;
|
||||
GLResourceRecord *ctxRecord;
|
||||
|
||||
@@ -1625,6 +1625,8 @@ void MakeShaderReflection(GLenum shadType, GLuint sepProg, ShaderReflection &ref
|
||||
|
||||
string name = namebuf;
|
||||
|
||||
delete[] namebuf;
|
||||
|
||||
res.name = name;
|
||||
|
||||
rdcarray<ShaderResource> &reslist = (res.isReadOnly ? roresources : rwresources);
|
||||
@@ -2016,7 +2018,10 @@ void MakeShaderReflection(GLenum shadType, GLuint sepProg, ShaderReflection &ref
|
||||
}
|
||||
|
||||
if(unused)
|
||||
{
|
||||
delete[] nm;
|
||||
continue;
|
||||
}
|
||||
|
||||
// VS built-in inputs
|
||||
if(IS_BUILTIN("gl_VertexID"))
|
||||
|
||||
@@ -239,7 +239,11 @@ glslang::TShader *CompileShaderForReflection(SPIRVShaderStage stage,
|
||||
|
||||
shader->setStrings(strs, (int)sources.size());
|
||||
|
||||
if(shader->parse(&DefaultResources, 100, false, EShMsgRelaxedErrors))
|
||||
bool success = shader->parse(&DefaultResources, 100, false, EShMsgRelaxedErrors);
|
||||
|
||||
delete[] strs;
|
||||
|
||||
if(success)
|
||||
{
|
||||
allocatedShaders->push_back(shader);
|
||||
return shader;
|
||||
|
||||
@@ -424,15 +424,18 @@ Socket *CreateClientSocket(const char *host, uint16_t port, int timeoutMS)
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_protocol = IPPROTO_TCP;
|
||||
|
||||
addrinfo *result = NULL;
|
||||
getaddrinfo(host, portstr, &hints, &result);
|
||||
addrinfo *addrResult = NULL;
|
||||
getaddrinfo(host, portstr, &hints, &addrResult);
|
||||
|
||||
for(addrinfo *ptr = result; ptr != NULL; ptr = ptr->ai_next)
|
||||
for(addrinfo *ptr = addrResult; ptr != NULL; ptr = ptr->ai_next)
|
||||
{
|
||||
int s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
|
||||
if(s == -1)
|
||||
{
|
||||
freeaddrinfo(addrResult);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int flags = fcntl(s, F_GETFL, 0);
|
||||
fcntl(s, F_SETFL, flags | O_NONBLOCK);
|
||||
@@ -475,9 +478,13 @@ Socket *CreateClientSocket(const char *host, uint16_t port, int timeoutMS)
|
||||
int nodelay = 1;
|
||||
setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char *)&nodelay, sizeof(nodelay));
|
||||
|
||||
freeaddrinfo(addrResult);
|
||||
|
||||
return new Socket((ptrdiff_t)s);
|
||||
}
|
||||
|
||||
freeaddrinfo(addrResult);
|
||||
|
||||
RDCDEBUG("Failed to connect to %s:%d", host, port);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -974,6 +974,13 @@ TEST_CASE("Test PID Node list handling", "[osspecific]")
|
||||
CHECK(list1.head->next->next->next == d);
|
||||
CHECK(list1.head->next->next->next->next == e);
|
||||
CHECK(list1.head->next->next->next->next->next == f);
|
||||
|
||||
delete a;
|
||||
delete b;
|
||||
delete c;
|
||||
delete d;
|
||||
delete e;
|
||||
delete f;
|
||||
};
|
||||
|
||||
#endif // ENABLED(ENABLE_UNIT_TESTS)
|
||||
|
||||
@@ -394,7 +394,10 @@ Socket *CreateClientSocket(const char *host, uint16_t port, int timeoutMS)
|
||||
WSA_FLAG_NO_HANDLE_INHERIT | WSA_FLAG_OVERLAPPED);
|
||||
|
||||
if(s == INVALID_SOCKET)
|
||||
{
|
||||
FreeAddrInfoW(addrResult);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
u_long enable = 1;
|
||||
ioctlsocket(s, FIONBIO, &enable);
|
||||
@@ -446,9 +449,13 @@ Socket *CreateClientSocket(const char *host, uint16_t port, int timeoutMS)
|
||||
BOOL nodelay = TRUE;
|
||||
setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (const char *)&nodelay, sizeof(nodelay));
|
||||
|
||||
FreeAddrInfoW(addrResult);
|
||||
|
||||
return new Socket((ptrdiff_t)s);
|
||||
}
|
||||
|
||||
FreeAddrInfoW(addrResult);
|
||||
|
||||
RDCDEBUG("Failed to connect to %s:%d", host, port);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user