1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-06 14:02:47 -05:00

Another big batch of memory leak fixes, again mostly on error paths.

The most interesting one is printer_add_enum, which I've modified to
take a char ** rather than a char * so that it can both realloc its
input buffer _and_ return NULL to indicate error.

[originally from svn r9959]
This commit is contained in:
Simon Tatham
2013-07-22 07:11:54 +00:00
parent 4c61cb20a1
commit b99bec3b02
9 changed files with 107 additions and 42 deletions

View File

@ -209,8 +209,10 @@ int agent_query(void *in, int inlen, void **out, int *outlen,
filemap = CreateFileMapping(INVALID_HANDLE_VALUE, psa, PAGE_READWRITE,
0, AGENT_MAX_MSGLEN, mapname);
if (filemap == NULL || filemap == INVALID_HANDLE_VALUE)
if (filemap == NULL || filemap == INVALID_HANDLE_VALUE) {
sfree(mapname);
return 1; /* *out == NULL, so failure */
}
p = MapViewOfFile(filemap, FILE_MAP_WRITE, 0, 0, 0);
memcpy(p, in, inlen);
cds.dwData = AGENT_COPYDATA_ID;
@ -237,6 +239,7 @@ int agent_query(void *in, int inlen, void **out, int *outlen,
data->hwnd = hwnd;
if (CreateThread(NULL, 0, agent_query_thread, data, 0, &threadid))
return 0;
sfree(mapname);
sfree(data);
}
#endif
@ -258,6 +261,7 @@ int agent_query(void *in, int inlen, void **out, int *outlen,
}
UnmapViewOfFile(p);
CloseHandle(filemap);
sfree(mapname);
if (psd)
LocalFree(psd);
sfree(usersid);