s3: Fix a valgrind error
authorVolker Lendecke <vl@samba.org>
Thu, 29 Mar 2012 12:16:04 +0000 (14:16 +0200)
committerVolker Lendecke <vl@samba.org>
Thu, 29 Mar 2012 13:50:13 +0000 (15:50 +0200)
Autobuild-User: Volker Lendecke <vl@samba.org>
Autobuild-Date: Thu Mar 29 15:50:13 CEST 2012 on sn-devel-104

source3/lib/messages.c

index 947a274..6a18e4f 100644 (file)
@@ -69,10 +69,17 @@ static void ping_message(struct messaging_context *msg_ctx,
                         struct server_id src,
                         DATA_BLOB *data)
 {
-       const char *msg = data->data ? (const char *)data->data : "none";
+       const char *msg = "none";
+       char *free_me = NULL;
 
+       if (data->data != NULL) {
+               free_me = talloc_strndup(talloc_tos(), (char *)data->data,
+                                        data->length);
+               msg = free_me;
+       }
        DEBUG(1,("INFO: Received PING message from PID %s [%s]\n",
                 procid_str_static(&src), msg));
+       TALLOC_FREE(free_me);
        messaging_send(msg_ctx, src, MSG_PONG, data);
 }