~mdw
/
sgt
/
putty
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix memory leaks in the new error return from modinv.
[sgt/putty]
/
raw.c
diff --git
a/raw.c
b/raw.c
index
5bf6356
..
1d9f854
100644
(file)
--- a/
raw.c
+++ b/
raw.c
@@
-4,6
+4,7
@@
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
+#include <limits.h>
#include "putty.h"
#include "putty.h"
@@
-21,6
+22,7
@@
typedef struct raw_backend_data {
/* the above field _must_ be first in the structure */
Socket s;
/* the above field _must_ be first in the structure */
Socket s;
+ int closed_on_socket_error;
int bufsize;
void *frontend;
int sent_console_eof, sent_socket_eof;
int bufsize;
void *frontend;
int sent_console_eof, sent_socket_eof;
@@
-48,6
+50,7
@@
static void raw_log(Plug plug, int type, SockAddr addr, int port,
msg = dupprintf("Failed to connect to %s: %s", addrbuf, error_msg);
logevent(raw->frontend, msg);
msg = dupprintf("Failed to connect to %s: %s", addrbuf, error_msg);
logevent(raw->frontend, msg);
+ sfree(msg);
}
static void raw_check_close(Raw raw)
}
static void raw_check_close(Raw raw)
@@
-75,6
+78,7
@@
static int raw_closing(Plug plug, const char *error_msg, int error_code,
if (raw->s) {
sk_close(raw->s);
raw->s = NULL;
if (raw->s) {
sk_close(raw->s);
raw->s = NULL;
+ raw->closed_on_socket_error = TRUE;
notify_remote_exit(raw->frontend);
}
logevent(raw->frontend, error_msg);
notify_remote_exit(raw->frontend);
}
logevent(raw->frontend, error_msg);
@@
-139,6
+143,7
@@
static const char *raw_init(void *frontend_handle, void **backend_handle,
raw = snew(struct raw_backend_data);
raw->fn = &fn_table;
raw->s = NULL;
raw = snew(struct raw_backend_data);
raw->fn = &fn_table;
raw->s = NULL;
+ raw->closed_on_socket_error = FALSE;
*backend_handle = raw;
raw->sent_console_eof = raw->sent_socket_eof = FALSE;
*backend_handle = raw;
raw->sent_console_eof = raw->sent_socket_eof = FALSE;
@@
-306,6
+311,8
@@
static int raw_exitcode(void *handle)
Raw raw = (Raw) handle;
if (raw->s != NULL)
return -1; /* still connected */
Raw raw = (Raw) handle;
if (raw->s != NULL)
return -1; /* still connected */
+ else if (raw->closed_on_socket_error)
+ return INT_MAX; /* a socket error counts as an unclean exit */
else
/* Exit codes are a meaningless concept in the Raw protocol */
return 0;
else
/* Exit codes are a meaningless concept in the Raw protocol */
return 0;