fix the check
authorDaniel Stenberg <daniel@haxx.se>
Thu, 25 Oct 2007 09:34:16 +0000 (09:34 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 25 Oct 2007 09:34:16 +0000 (09:34 +0000)
lib/tftp.c

index 041a5f3..4e0b6de 100644 (file)
@@ -612,10 +612,12 @@ static CURLcode Curl_tftp_connect(struct connectdata *conn, bool *done)
      sessionhandle, deal with it */
   Curl_reset_reqproto(conn);
 
-  state = conn->data->reqdata.proto.tftp = calloc(sizeof(tftp_state_data_t),
-                                                  1);
-  if(!state)
-    return CURLE_OUT_OF_MEMORY;
+  if(!(state = conn->data->reqdata.proto.tftp)) {
+    state = conn->data->reqdata.proto.tftp = calloc(sizeof(tftp_state_data_t),
+                                                    1);
+    if(!state)
+      return CURLE_OUT_OF_MEMORY;
+  }
 
   conn->bits.close = FALSE; /* keep it open if possible */