mirror of
https://github.com/docker/docker-credential-helpers.git
synced 2026-06-13 16:01:28 +05:30
implemented freeing memory in secretservice and made minor edits to osxkeychain
Signed-off-by: Avi Vaid <avaid1996@gmail.com>
This commit is contained in:
@@ -10,11 +10,11 @@ package osxkeychain
|
||||
import "C"
|
||||
import (
|
||||
"errors"
|
||||
"github.com/docker/docker-credential-helpers/credentials"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"unsafe"
|
||||
"github.com/docker/docker-credential-helpers/credentials"
|
||||
)
|
||||
|
||||
// errCredentialsNotFound is the specific error message returned by OS X
|
||||
@@ -106,7 +106,7 @@ func (h Osxkeychain) List() ([]string, []string, error){
|
||||
goMsg := C.GoString(errMsg)
|
||||
return nil, nil, errors.New(goMsg)
|
||||
}
|
||||
var listLen int;
|
||||
var listLen int
|
||||
listLen = int(listLenC)
|
||||
pathTmp := (*[1 << 30]*C.char)(unsafe.Pointer(pathsC))[:listLen:listLen]
|
||||
acctTmp := (*[1 << 30]*C.char)(unsafe.Pointer(acctsC))[:listLen:listLen]
|
||||
@@ -124,9 +124,8 @@ func (h Osxkeychain) List() ([]string, []string, error){
|
||||
}
|
||||
paths = paths[:at]
|
||||
accts = accts[:at]
|
||||
//still need to free all the memory we allocated in the c file
|
||||
//do it here >>
|
||||
C.freeListData(&pathsC, listLenC)
|
||||
C.freeListData(&acctsC, listLenC)
|
||||
return paths, accts, nil
|
||||
}
|
||||
|
||||
@@ -164,4 +163,3 @@ func freeServer(s *C.struct_Server) {
|
||||
C.free(unsafe.Pointer(s.host))
|
||||
C.free(unsafe.Pointer(s.path))
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "secretservice_linux.h"
|
||||
|
||||
const SecretSchema *docker_get_schema(void)
|
||||
@@ -137,3 +138,10 @@ GError *list(char *** paths, char *** accts, unsigned int *list_l) {
|
||||
*list_l = numKeys;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void freeListData(char *** data, unsigned int length) {
|
||||
for(int i=0; i<length; i++) {
|
||||
free((*data)[i]);
|
||||
}
|
||||
free(*data);
|
||||
}
|
||||
|
||||
@@ -99,5 +99,7 @@ func (h Secretservice) List() ([]string, []string, error) {
|
||||
paths[i] = C.GoString(pathTmp[i])
|
||||
accts[i] = C.GoString(acctTmp[i])
|
||||
}
|
||||
C.freeListData(&pathsC, listLenC)
|
||||
C.freeListData(&acctsC, listLenC)
|
||||
return paths, accts, nil
|
||||
}
|
||||
|
||||
@@ -10,3 +10,4 @@ GError *add(char *server, char *username, char *secret);
|
||||
GError *delete(char *server);
|
||||
GError *get(char *server, char **username, char **secret);
|
||||
GError *list(char *** paths, char *** accts, unsigned int *list_l);
|
||||
void freeListData(char *** data, unsigned int length);
|
||||
|
||||
Reference in New Issue
Block a user