100+ results for 'safe_free'

Not the results you expected?

vfs_aixacl.c (https://bitbucket.org/knarf/samba.git) C · 197 lines

57 struct acl *new_acl = SMB_MALLOC(file_acl->acl_len + sizeof(struct acl));

58 if( new_acl == NULL) {

59 SAFE_FREE(file_acl);

60 errno = ENOMEM;

61 return NULL;

65 if( rc == -1) {

66 DEBUG(0,("statacl returned %d with errno %d\n",rc,errno));

67 SAFE_FREE(file_acl);

68 return(NULL);

69 }

74

75 result = aixacl_to_smbacl(file_acl, mem_ctx);

76 SAFE_FREE(file_acl);

77 return result;

78

perfcount.c (https://github.com/theresahalloran/samba-tool-time-doc.git) C · 193 lines

133 */

134

135 SAFE_FREE(module_name);

136 module_name = smb_xstrdup(strrchr_m(module_path, '/')+1);

137

156 g_smb_perfcount_handlers = entry->handlers;

157

158 SAFE_FREE(module_path);

159 SAFE_FREE(module_name);

161

162 fail:

163 SAFE_FREE(module_path);

164 SAFE_FREE(module_name);

afs_settoken.c (https://github.com/rhuitl/uClinux.git) C · 239 lines

224 result = afs_settoken(cell, &ct, ticket);

225

226 SAFE_FREE(cell);

227 data_blob_free(&ticket);

228

smbreadline.c (https://bitbucket.org/knarf/samba.git) C · 185 lines

97 ret = x_fgets(line, BUFSIZ, x_stdin);

98 if (ret == 0) {

99 SAFE_FREE(line);

100 }

101 return ret;

105 }

106 }

107 SAFE_FREE(line);

108 return NULL;

109 }

el_analyze.c (https://github.com/wertarbyte/ettercap.git) C · 199 lines

81 }

82

83 SAFE_FREE(buf);

84 }

85

132 profile_add_info(&inf, &buf);

133

134 SAFE_FREE(buf.user);

135 SAFE_FREE(buf.pass);

136 SAFE_FREE(buf.info);

137 SAFE_FREE(buf.banner);

unlock.c (https://github.com/BeyondTrust/pbis-open.git) C · 208 lines

175 if (avpMod) {

176 for (i = 0; avpMod[i].vals; ++i) {

177 LW_SAFE_FREE_MEMORY(avpMod[i].vals);

178 }

179

180 LW_SAFE_FREE_MEMORY(avpMod);

181 }

182

184 for (i = 0; avp[i].vals; ++i) {

185 for (j = 0; avp[i].vals[j]; ++j) {

186 LW_SAFE_FREE_MEMORY(avp[i].vals[j]);

187 }

188

domainclientsrights.c (https://github.com/vmware/lightwave.git) C · 304 lines

32 TestAssertEquals(dwError, 0);

33

34 VMDIR_SAFE_FREE_STRINGA(pszUserName);

35 return dwError;

36 }

69 TestAssertStrEquals(pszAttribute, pszUserName);

70

71 VMDIR_SAFE_FREE_STRINGA(pszAttribute);

72 return dwError;

73 }

106 TestAssert(strlen(pszAttribute) > 0);

107

108 VMDIR_SAFE_FREE_STRINGA(pszAttribute);

109 return dwError;

110 }

utils.c (https://github.com/nexgenta/redbutton.git) C · 269 lines

165 /*

166 * safe_realloc(NULL, n) == safe_malloc(n)

167 * safe_realloc(x, 0) == safe_free(x) and returns NULL

168 */

169

175 if(nbytes == 0)

176 {

177 safe_free(oldbuf);

178 return NULL;

179 }

206

207 /*

208 * safe_free(NULL) is okay

209 */

210

csuperlog.cpp (https://github.com/pauldotknopf/WindowsSDK7-Samples.git) C++ · 292 lines

28 #define SAFE_SYSALLOC(pv, bstr) { pv = SysAllocString(bstr); CHECK_MEMORY(pv); }

29

30 #define SAFE_FREE(pv) { CoTaskMemFree(pv); pv = NULL; }

31 #define SAFE_SYSFREE(bstr) { SysFreeString(bstr); bstr = NULL; }

32

179 mbstowcs(pwsz, szVal, len+1);

180 OutputText(pwsz);

181 SAFE_FREE(pwsz);

182 }

183

dprintf.c (https://github.com/rhuitl/uClinux.git) C · 113 lines

57 p2 = (char *)SMB_MALLOC(maxlen);

58 if (!p2) {

59 SAFE_FREE(p);

60 return -1;

61 }

65 /* it didn't fit - try a larger buffer */

66 maxlen *= 2;

67 SAFE_FREE(p2);

68 goto again;

69 }

70

71 /* good, its converted OK */

72 SAFE_FREE(p);

73 ret = fwrite(p2, 1, clen, f);

74 SAFE_FREE(p2);

traj.c (http://idmclib.googlecode.com/svn/trunk/) C · 160 lines

24 #include "traj.h"

25

26 #define SAFE_FREE(p) if(p!=NULL) free(p)

27

28 int idmc_traj_trajectory_alloc(idmc_model *model, double *parValues, double *varValues, idmc_traj_trajectory **out_ans) {

58 if(traj->model != NULL)

59 idmc_model_free(traj->model);

60 SAFE_FREE(traj->par);

61 SAFE_FREE(traj->var);

62 SAFE_FREE(traj);

63 }

64

138 if (trajectory->step_function!=NULL)

139 gsl_odeiv_step_free(trajectory->step_function);

140 SAFE_FREE(trajectory->error);

141 SAFE_FREE(trajectory->var);

c_path.h (https://gitlab.com/rpdev/csync) C Header · 136 lines

126 * @param pathSrc The path to parse.

127 *

128 * @return Returns a C_PATHINFO structure that should be freed using SAFE_FREE().

129 */

130 C_PATHINFO * c_split_path(const char* pathSrc);

tdnfpyrepodata.c (https://github.com/vmware/tdnf.git) C · 289 lines

151

152 cleanup:

153 TDNF_SAFE_FREE_MEMORY(pszRepr);

154 return pyRepr;

155

task_range.cc (https://github.com/blender/blender.git) C++ · 168 lines

74 settings->func_free(userdata, userdata_chunk);

75 }

76 MEM_SAFE_FREE(userdata_chunk);

77 }

78

samr_cfg.c (https://github.com/BeyondTrust/pbis-open.git) C · 324 lines

94 if (pConfig)

95 {

96 LW_SAFE_FREE_STRING(pConfig->pszLpcSocketPath);

97 LW_SAFE_FREE_STRING(pConfig->pszDefaultLoginShell);

98 LW_SAFE_FREE_STRING(pConfig->pszHomedirPrefix);

99 LW_SAFE_FREE_STRING(pConfig->pszHomedirTemplate);

common.h (https://github.com/XadillaX/byakuren.git) C Header · 151 lines

69

70 #define SAFE_DESTROY_POOL(pool) if(pool) { xmem_destroy_pool(pool); pool = NULL; }

71 #define SAFE_FREE(pointer) if(pointer) { free(pointer); pointer = NULL; }

72 #define MAX_INT (2147483647)

73 #define BKR_RGB_TO_INT32(r, g, b) (((r) << 16) + ((g) << 8) + (b))

vfs_readahead.c (https://github.com/theresahalloran/samba-tool-time-doc.git) C · 186 lines

122 static void free_readahead_data(void **pptr)

123 {

124 SAFE_FREE(*pptr);

125 }

126

tsip_header_WWW_Authenticate.c (https://gitlab.com/iwan.aucamp/doubango) C · 160 lines

101 TSIP_HEADER(sip_hdr)->params = tsk_object_ref(THTTP_HEADER(http_hdr)->params);

102

103 TSK_OBJECT_SAFE_FREE(http_hdr);

104 }

105

142 TSK_FREE(WWW_Authenticate->qop);

143

144 TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(WWW_Authenticate));

145 }

146 else{

ob_malloc.h (https://github.com/daseECNU/Cedar.git) C Header · 233 lines

41 /// @fn 释放通过ob_malloc获取的内存

42 void ob_free(void *ptr, const int32_t mod_id = 0);

43 void ob_safe_free(void *&ptr, const int32_t mod_id = 0);

44

45 ObTSIBlockAllocator& get_global_tsi_block_allocator();

utils.c (https://github.com/vmware/lightwave.git) C · 186 lines

109

110 cleanup:

111 VMDIR_SAFE_FREE_MEMORY(pszDomainName);

112 return dwError;

113

defines.h (https://github.com/vmware/lightwave.git) C Header · 154 lines

146 #define SEC_SUCCESS(Status) ((Status) >= 0)

147

148 #define IDM_SAFE_FREE_MEMORY(PTR) \

149 do { \

150 if ((PTR)) { \

ec_dissect.c (https://github.com/bonsaiviking/ettercap.git) C · 316 lines

164 /* retrieve the session and delete it */

165 if (session_get_and_del(&s, ident, DISSECT_IDENT_LEN) == -ENOTFOUND) {

166 SAFE_FREE(ident);

167 return;

168 }

170 /* free the session */

171 session_free(s);

172 SAFE_FREE(ident);

173 }

174

209 del_decoder(e->level, e->type);

210 SLIST_REMOVE(&dissect_list, e, dissect_entry, next);

211 SAFE_FREE(e);

212 }

213 }

check_std_c_rbtree.c (https://gitlab.com/rpdev/csync) C · 367 lines

61

62 freedata = (test_t *) data;

63 SAFE_FREE(freedata);

64 }

65

170

171 testdata = c_rbtree_node_data(node);

172 SAFE_FREE(testdata);

173 rc = c_rbtree_node_delete(node);

174 assert_int_equal(rc, 0);

lsasqlite.h (https://github.com/BeyondTrust/pbis-open.git) C Header · 207 lines

49 #include <lw/security-types.h>

50

51 #define SQLITE3_SAFE_FREE_STRING(x) \

52 if ((x) != NULL) \

53 { \

nameEntry.c (https://github.com/vmware/lightwave.git) C · 207 lines

77 {

78 VmDnsRecordListRelease(pNameEntry->pRecords);

79 VMDNS_SAFE_FREE_STRINGA(pNameEntry->pszName);

80 VmDnsFreeMemory(pNameEntry);

81 }

winbindd_nss.h (https://github.com/rhuitl/uClinux.git) C Header · 229 lines

22 */

23

24 #ifndef SAFE_FREE

25 #define SAFE_FREE(x) do { if(x) {free(x); x=NULL;} } while(0)

filemap.c (https://github.com/rhuitl/uClinux.git) C · 172 lines

151 filemapFreeMemory(fileMap * fm)

152 {

153 safe_free(fm->file_map);

154 safe_free(fm);

ec_dispatcher.c (https://github.com/bonsaiviking/ettercap.git) C · 175 lines

122 clean_exit(0);

123 else {

124 SAFE_FREE(e);

125 continue;

126 }

135 /* destroy the duplicate packet object */

136 packet_destroy_object(e->po);

137 SAFE_FREE(e->po);

138 SAFE_FREE(e);

ec_curses_logging.c (git://pkgs.fedoraproject.org/ettercap) C · 166 lines

78

79 /* make sure to free if already set */

80 SAFE_FREE(logfile);

81 SAFE_CALLOC(logfile, FILE_LEN, sizeof(char));

82

93

94 set_loglevel(LOG_PACKET, logfile);

95 SAFE_FREE(logfile);

96 }

97

104

105 /* make sure to free if already set */

106 SAFE_FREE(logfile);

107 SAFE_CALLOC(logfile, FILE_LEN, sizeof(char));

108

ec_smtp.c (https://github.com/bonsaiviking/ettercap.git) C · 193 lines

122 dissect_create_ident(&ident, PACKET, DISSECT_CODE(dissector_smtp));

123 if (session_get(&s, ident, DISSECT_IDENT_LEN) == -ENOTFOUND) {

124 SAFE_FREE(ident);

125 return NULL;

126 }

127

128 SAFE_FREE(ident);

129

130 /* the session is invalid */

145 i = base64_decode(user, ptr);

146

147 SAFE_FREE(s->data);

148

149 /* store the username in the session */

ec_hook.c (https://github.com/wertarbyte/ettercap.git) C · 157 lines

124 if (current->point == point && current->func == func) {

125 LIST_REMOVE(current, next);

126 SAFE_FREE(current);

127 HOOK_PCK_UNLOCK;

128 DEBUG_MSG("hook_del -- %d [%p]", point, func);

138 if (current->point == point && current->func == func) {

139 LIST_REMOVE(current, next);

140 SAFE_FREE(current);

141 HOOK_UNLOCK;

142 DEBUG_MSG("hook_del -- %d [%p]", point, func);

djservicemgr.c (https://github.com/BeyondTrust/pbis-open.git) C · 223 lines

64 cleanup:

65

66 LW_SAFE_FREE_MEMORY(pwszServiceName);

67

68 if (hHandle)

125 cleanup:

126

127 LW_SAFE_FREE_MEMORY(pwszServiceName);

128 LW_SAFE_FREE_MEMORY(pszTemp);

197 cleanup:

198

199 LW_SAFE_FREE_MEMORY(pwszServiceName);

200 LW_SAFE_FREE_MEMORY(pszTemp);

parseargs.c (https://github.com/vmware/lightwave.git) C · 268 lines

31 }

32

33 VMDIR_SAFE_FREE_MEMORY(ppszArgs[dwDelIdx]);

34

35 for (i = dwDelIdx; ppszArgs[i+1]; i++)

switch_buffer.c (https://github.com/tzuryby/mod_conference-admin.git) C · 349 lines

331 if (buffer && *buffer) {

332 if ((switch_test_flag((*buffer), SWITCH_BUFFER_FLAG_DYNAMIC))) {

333 switch_safe_free((*buffer)->data);

334 free(*buffer);

335 }

ematch_instance.c (https://github.com/SRI-CSL/yices2.git) C · 233 lines

69 for(i=n; i<table->ninstances; i++) {

70 inst = &table->data[i];

71 safe_free(inst->vdata);

72 safe_free(inst->odata);

105 shrink_instance_table(table, 0);

106

107 safe_free(table->data);

108 table->data = NULL;

109 delete_int_htbl(&table->htbl);

ptr_sets2.h (https://github.com/SRI-CSL/yices2.git) C Header · 186 lines

101 */

102 static inline void free_ptr_set2(ptr_set2_t *s) {

103 safe_free(s);

104 }

105

test_tpdu.h (https://gitlab.com/iwan.aucamp/doubango) C Header · 250 lines

47 TSK_FREE(hex);

48 }

49 TSK_OBJECT_SAFE_FREE(buffer);

50 }

51

55 // send(socket, buffer->data, buffer->size);

56

57 TSK_OBJECT_SAFE_FREE(submit);

58 submit = (tsms_tpdu_submit_t*)tsms_tpdu_message_deserialize_mo(buffer->data, buffer->size);

59 if((hex = tsms_tpdu_submit_tohexastring(submit))){

62 }

63

64 TSK_OBJECT_SAFE_FREE(submit);

65 TSK_OBJECT_SAFE_FREE(buffer);

84 TSK_FREE(hex);

85 }

86 TSK_OBJECT_SAFE_FREE(buffer);

87 }

88

upload.cpp (http://miranda.googlecode.com/svn/trunk/) C++ · 104 lines

56 break;

57

58 SAFE_FREE(&szValue);

59 if (!list[i].text) return def;

60

mp_net_transport.h (https://github.com/DoubangoTelecom/webrtc2sip.git) C Header · 168 lines

51 virtual ~MPNetPeer()

52 {

53 TSK_OBJECT_SAFE_FREE(m_pWrappedBuffer);

54 }

55 virtual MP_INLINE MPNetFd getFd(){ return m_nFd; }

ctarray.c (https://github.com/BeyondTrust/pbis-open.git) C · 135 lines

112 void CTArrayFree(DynamicArray *array)

113 {

114 CT_SAFE_FREE_MEMORY(array->data);

115 array->size = 0;

116 array->capacity = 0;

lsapam.c (https://github.com/BeyondTrust/pbis-open.git) C · 152 lines

112 {

113 LsaUtilFreePamConfigContents(pConfig);

114 LW_SAFE_FREE_MEMORY(pConfig);

115 }

116

124 DWORD i;

125

126 LW_SAFE_FREE_STRING(pConfig->pszAccessDeniedMessage);

127 LW_SAFE_FREE_STRING(pConfig->pszActiveDirectoryPasswordPrompt);

128 LW_SAFE_FREE_STRING(pConfig->pszLocalPasswordPrompt);

129 LW_SAFE_FREE_STRING(pConfig->pszOtherPasswordPrompt);

131 for (i = 0; i < pConfig->dwNumSmartCardServices; ++i)

132 {

133 LW_SAFE_FREE_STRING(pConfig->ppszSmartCardServices[i]);

134 }

135 LW_SAFE_FREE_MEMORY(pConfig->ppszSmartCardServices);

samr_contexthandle.c (https://github.com/BeyondTrust/pbis-open.git) C · 141 lines

62 SamrSrvFreeAuthInfo(pConnCtx);

63

64 LW_SAFE_FREE_MEMORY(pConnCtx);

65 }

66

75

76 RTL_FREE(&pDomCtx->pDomainSid);

77 LW_SAFE_FREE_MEMORY(pDomCtx->pwszDomainName);

78 LW_SAFE_FREE_MEMORY(pDomCtx->pwszDn);

80 SamrSrvConnectContextFree(pDomCtx->pConnCtx);

81

82 LW_SAFE_FREE_MEMORY(pDomCtx);

83 }

84

92 if (pAcctCtx->refcount) return;

93

94 LW_SAFE_FREE_MEMORY(pAcctCtx->pwszDn);

95 LW_SAFE_FREE_MEMORY(pAcctCtx->pwszName);

netinfo.c (https://github.com/BeyondTrust/pbis-open.git) C · 570 lines

205 pNetAdapterList = pNetAdapterList->pNext;

206

207 LW_SAFE_FREE_STRING(pTemp->pszName);

208 LW_SAFE_FREE_STRING(pTemp->pszENetAddress);

209 LW_SAFE_FREE_STRING(pTemp->pszIPAddress);

210

211 LwFreeMemory(pTemp);

c.vim (https://github.com/dumuzid/exVim.git) Vim Script · 124 lines

21 syn keyword cStatement ex_realloc ex_realloc_use ex_realloc_nomanage ex_realloc_tag ex_realloc_tag_use

22 syn keyword cStatement ex_free ex_free_use ex_free_nomanage

23 syn keyword cStatement ex_safe_free ex_safe_free_use ex_safe_free_nomanage

24 syn keyword cStatement ex_stack_malloc

25 syn keyword cStatement ex_log ex_error ex_warning ex_log_func ex_assert ex_assert_slow ex_assert_return ex_assert_exec ex_check ex_check_return ex_check_exec ex_static_assert ex_compile_time_assert

fapi-quote-destructive.int.c (https://github.com/tpm2-software/tpm2-tss.git) C · 147 lines

116 goto_if_error(r, "Error Fapi_Delete", error);

117

118 SAFE_FREE(pubkey_pem);

119 SAFE_FREE(signature);

120 SAFE_FREE(quoteInfo);

121 SAFE_FREE(pcrEventLog);

122 SAFE_FREE(certificate);

123 SAFE_FREE(export_data);

124 SAFE_FREE(pcr_digest);

125 SAFE_FREE(log);

126 SAFE_FREE(pathlist);

127 return EXIT_SUCCESS;

128

publish.c (https://gitlab.com/iwan.aucamp/doubango) C · 117 lines

105 /* Any other TSIP_ACTION_SET_*() macros */

106 TSIP_ACTION_SET_NULL());

107 TSK_OBJECT_SAFE_FREE(action_config);

108 break;

109 }

sspi.c (https://github.com/vmware/lightwave.git) C · 288 lines

210

211 error:

212 IDM_SAFE_FREE_MEMORY(pOutputBuffer);

213

214 goto cleanup;

281 }

282

283 IDM_SAFE_FREE_MEMORY(pAuthContext);

284

285 pAuthContext = NULL;

ads_struct.c (https://bitbucket.org/knarf/samba.git) C · 213 lines

112

113 if (!strlower_m( dnsdomain )) {

114 SAFE_FREE(dnsdomain);

115 return NULL;

116 }

188 ads_disconnect(*ads);

189 #endif

190 SAFE_FREE((*ads)->server.realm);

191 SAFE_FREE((*ads)->server.workgroup);

192 SAFE_FREE((*ads)->server.ldap_server);

193

194 SAFE_FREE((*ads)->auth.realm);

195 SAFE_FREE((*ads)->auth.password);

196 SAFE_FREE((*ads)->auth.user_name);

lwunistr.c (https://github.com/BeyondTrust/pbis-open.git) C · 687 lines

94

95 cleanup:

96 LW_SAFE_FREE_MEMORY(pwszTruncated);

97

98 return dwError;

255

256 error:

257 LW_SAFE_FREE_MEMORY(pwszStrOutput);

258

259 goto cleanup;

343

344 error:

345 LW_SAFE_FREE_MEMORY(pwszOutputString);

346

347 *ppwszOutputString = NULL;

memcache.c (https://github.com/theuni/XBMC-deps.git) C · 436 lines

64 for (e = cache->mru; e != NULL; e = next) {

65 next = e->next;

66 SAFE_FREE(e);

67 }

68 return 0;

219 cache->size -= memcache_element_size(e->keylength, e->valuelength);

220

221 SAFE_FREE(e);

222 }

223

int_queues.c (https://github.com/SRI-CSL/yices2.git) C · 169 lines

48 */

49 void delete_int_queue(int_queue_t *q) {

50 safe_free(q->data);

51 q->data = NULL;

52 }

kerberos_util.c (https://bitbucket.org/mikedep333/rdssamba4.git) C · 107 lines

51 password, ads->auth.time_offset);

52

53 SAFE_FREE(principal);

54 return status;

55 }

89

90 if (!ads->auth.password) {

91 SAFE_FREE(s);

92 return KRB5_LIBOS_CANTREADPWD;

93 }

101 s, error_message(ret)));

102 }

103 SAFE_FREE(s);

104 return ret;

105 }

Cookie_FireFox.cpp (https://github.com/hackedteam/core-win32.git) C++ · 200 lines

67 AddCookieA(host, name, value);

68

69 SAFE_FREE(host);

70 SAFE_FREE(name);

71 SAFE_FREE(value);

72

73 return 0;

88

89 sprintf_s(sqlPath, MAX_PATH, "%s\\%S", ascii_path, signonFile);

90 SAFE_FREE(ascii_path);

91

92 if ((rc = social_SQLITE_open(sqlPath, &db)))

128 if (!ReadFile(h_session_file, session_memory, session_size, &n_read, NULL)) {

129 CloseHandle(h_session_file);

130 SAFE_FREE(session_memory);

131 return 0;

132 }

system_smbd.c (https://github.com/theuni/XBMC-deps.git) C · 198 lines

64 ngrp_saved = getgroups(ngrp_saved, gids_saved);

65 if (ngrp_saved == -1) {

66 SAFE_FREE(gids_saved);

67 /* very strange! */

68 return -1;

71 if (initgroups(user, gid) != 0) {

72 DEBUG(0, ("getgrouplist_internals: initgroups() failed!\n"));

73 SAFE_FREE(gids_saved);

74 return -1;

75 }

83 num_gids = getgroups(0, NULL);

84 if (num_gids == -1) {

85 SAFE_FREE(gids_saved);

86 /* very strange! */

87 return -1;

DecUT_ErrorConcealment.cpp (https://gitlab.com/generic-library/openh264) C++ · 294 lines

27 if (pECCtx != NULL) {

28 if (pECCtx->pCtx != NULL) {

29 WELS_SAFE_FREE (pECCtx->pCtx->pSps, "pECCtx->pCtx->pSps");

30 WELS_SAFE_FREE (pECCtx->pCtx, "pECCtx->pCtx");

31 }

32

33 WELS_SAFE_FREE (pECCtx->pMbCorrectlyDecodedFlag, "pECCtx->pMbCorrectlyDecodedFlag");

34 WELS_SAFE_FREE (pECCtx->sSrcPic.pData[0], "pECCtx->sSrcPic.pData");

35 WELS_SAFE_FREE (pECCtx->sAncPic.pData[0], "pECCtx->sAncPic.pData");

36 WELS_SAFE_FREE (pECCtx->sWelsPic.pData[0], "pECCtx->sWelsPic.pData");

37

38 WELS_SAFE_FREE (pECCtx, "pECCtx");

39 }

40 }

idmap_cache.c (https://github.com/theuni/XBMC-deps.git) C · 260 lines

53 uid = strtol(value, &endptr, 10);

54 ret = (*endptr == '\0');

55 SAFE_FREE(value);

56 if (ret) {

57 *puid = uid;

91 ret = string_to_sid(sid, value);

92 }

93 SAFE_FREE(value);

94 if (ret) {

95 *expired = (timeout <= time(NULL));

173 gid = strtol(value, &endptr, 10);

174 ret = (*endptr == '\0');

175 SAFE_FREE(value);

176 if (ret) {

177 *pgid = gid;

memory_policy.hpp (https://github.com/triAGENS/ArangoDB.git) C++ Header · 142 lines

116 #else

117 #if IMMER_NO_THREAD_SAFETY

118 using default_heap_policy = unsafe_free_list_heap_policy<cpp_heap>;

119 #else

120 using default_heap_policy = free_list_heap_policy<cpp_heap>;

ec_connbuf.c (https://github.com/0x0mar/ettercap.git) C · 184 lines

79 if (p->size > cb->max_size) {

80 DEBUG_MSG("connbuf_add: buffer too small %d %d\n", (int)cb->max_size, (int)p->size);

81 SAFE_FREE(p);

82 return 0;

83 }

106 cb->size -= e->size;

107 /* remove the elemnt */

108 SAFE_FREE(e->buf);

109 TAILQ_REMOVE(&cb->connbuf_tail, e, next);

110 SAFE_FREE(e);

138 while ((e = TAILQ_FIRST(&cb->connbuf_tail)) != TAILQ_END(&cb->connbuf_tail)) {

139 TAILQ_REMOVE(&cb->connbuf_tail, e, next);

140 SAFE_FREE(e->buf);

141 SAFE_FREE(e);

vfs_dirsort.c (https://github.com/theresahalloran/samba-tool-group-doc.git) C · 237 lines

39 static void free_dirsort_privates(void **datap) {

40 struct dirsort_privates *data = (struct dirsort_privates *) *datap;

41 SAFE_FREE(data->directory_list);

42 SAFE_FREE(data);

72

73 /* Set up an array and read the directory entries into it */

74 SAFE_FREE(data->directory_list); /* destroy previous cache if needed */

75 data->directory_list = (SMB_STRUCT_DIRENT *)SMB_MALLOC(

76 data->number_of_entries * sizeof(SMB_STRUCT_DIRENT));

148

149 if (data->source_directory == NULL) {

150 SAFE_FREE(data);

151 return NULL;

152 }

csched_test.c (https://github.com/hse-project/hse.git) C · 309 lines

34 mocked_sp_destroy(struct csched_ops *handle)

35 {

36 mapi_safe_free(handle);

37 }

38

spline.c (https://gitlab.com/marcelosabino/gimp) C · 233 lines

151 {

152 if (SPLINE_LIST_DATA (*spline_list) != NULL)

153 safe_free ((address *) &(SPLINE_LIST_DATA (*spline_list)));

154 }

155

218

219 if (SPLINE_LIST_ARRAY_DATA (*spline_list_array) != NULL)

220 safe_free ((address *) &(SPLINE_LIST_ARRAY_DATA (*spline_list_array)));

221 }

222

conncache.c (https://github.com/theresahalloran/samba-tool-group-doc.git) C · 226 lines

45 * @param[in] server may be a FQDN or an IP address

46 * @return the resulting string, which the caller is responsible for

47 * SAFE_FREE()ing

48 * @retval NULL returned on error

49 */

73 * @param[in] status

74 * @return the resulting string, which the caller is responsible for

75 * SAFE_FREE()ing

76 * @retval NULL returned on error

77 */

150 "server %s\n", NT_STATUS_V(result), domain, server));

151 TALLOC_FREE(key);

152 SAFE_FREE(value);

153 return result;

154 }

gentools_s.c (https://github.com/MmgTools/mmg.git) C · 177 lines

115 pt->ref = ref;

116 }

117 MMG5_SAFE_FREE(list);

118 return 1;

119 }

resolvconf.c (https://gitlab.com/miztake/samba) C · 123 lines

90 }

91

92 SAFE_FREE(line);

93

94 if (ret == 0) {

gc_hal_mem.h (https://gitlab.com/gioge/linux-imx_3.10.53_1.1.0_ga) C Header · 530 lines

335 gceSTATUS status; \

336 gcmHEADER_ARG("MemPool=0x%x Pointer=0x%x", MemPool, Pointer); \

337 status = gcmOS_SAFE_FREE(MemPool, Pointer); \

338 gcmFOOTER(); \

339 return status; \

382 gceSTATUS status; \

383 gcmHEADER_ARG("MemPool=0x%x Pointer=0x%x", MemPool, Pointer); \

384 status = gcmOS_SAFE_FREE(MemPool, Pointer); \

385 gcmFOOTER(); \

386 return status; \

429 gceSTATUS status; \

430 gcmHEADER_ARG("MemPool=0x%x Pointer=0x%x", MemPool, Pointer); \

431 status = gcmOS_SAFE_FREE(MemPool, Pointer); \

432 gcmFOOTER(); \

433 return status; \

xgselect.c (https://github.com/jwiegley/emacs-release.git) C · 164 lines

92 }

93

94 SAFE_FREE ();

95

96 if (tmo_in_millisec >= 0)

defs.ns.h (https://github.com/restorer/zemu.git) C Header · 95 lines

87 void* safe_alloc(size_t size);

88 void safe_realloc(void** ptr, size_t size);

89 void safe_free(void* ptr);

90 char* alloc_n_strcpy(const char* str);

91 char* alloc_n_sprintf(const char* fmt, ...);

md5.patch (https://github.com/energy6/xbmc.git) Patch · 72 lines

21 + ctx = ssh_md5_init();

22 if (ctx == NULL) {

23 SAFE_FREE(h);

24 return SSH_ERROR;

25 diff -ruN src/kex.c src/kex.c

regdbutil.c (https://github.com/vmware/lightwave.git) C · 352 lines

69 }

70

71 VMAFD_SAFE_FREE_STRINGA(pszValue);

72

73 return dwError;

150 }

151

152 VMAFD_SAFE_FREE_STRINGA(pszValue);

153

154 return dwError;

principal.c (https://github.com/vmware/lightwave.git) C · 366 lines

27 if (pPrincipal->components) {

28 for (i=0; i<(int) pPrincipal->numComponents; i++) {

29 VMKDC_SAFE_FREE_DATA(pPrincipal->components[i]);

30 }

31 VMKDC_SAFE_FREE_MEMORY(pPrincipal->components);

32 }

33 VMKDC_SAFE_FREE_DATA(pPrincipal->realm);

34 VMKDC_SAFE_FREE_MEMORY(pPrincipal->name);

35 VMKDC_SAFE_FREE_MEMORY(pPrincipal);

36 }

37 }

50 if (dwError)

51 {

52 VMKDC_SAFE_FREE_PRINCIPAL(pPrincipal);

53 }

54 *ppRetPrincipal = pPrincipal;

ms_fnmatch.c (https://github.com/endisd/samba.git) C · 238 lines

225 ret = ms_fnmatch_core(p, s, max_n, strrchr_w(s, UCS2_CHAR('.')), is_case_sensitive);

226

227 SAFE_FREE(max_n_free);

228 TALLOC_FREE(p);

229 TALLOC_FREE(s);

lookup_table.cpp (https://github.com/xiaochuanle/MECAT.git) C++ · 160 lines

7 destroy_ref_index(ref_index* ridx)

8 {

9 safe_free(ridx->kmer_counts);

10 safe_free(ridx->kmer_starts);

11 safe_free(ridx->kmer_offsets);

12 safe_free(ridx);

networkutiluniximpl.c (https://github.com/vmware/lightwave.git) C · 347 lines

71 close (socket_fd);

72 }

73 VMDIR_SAFE_FREE_MEMORY (pConnection);

74 goto cleanup;

75 }

146 close (socket_fd);

147 }

148 VMDIR_SAFE_FREE_MEMORY(pConnection);

149 goto cleanup;

150 }

188 error:

189 if (pTempConnection){

190 VMDIR_SAFE_FREE_MEMORY(pTempConnection);

191 }

192 if (ppConnection){

svdutil.h (https://github.com/amumu/divisi2.git) C Header · 121 lines

4 #include "svdlib.h"

5

6 #define SAFE_FREE(a) {if (a) {free(a); a = NULL;}}

7

8 /* Allocates an array of longs. */

net_status.c (https://github.com/theresahalloran/samba-tool-group-doc.git) C · 243 lines

180 connections_forall_read(show_share_parseable, &ids);

181

182 SAFE_FREE(ids.entries);

183

184 return 0;

ec_ui.c (git://pkgs.fedoraproject.org/ettercap) C · 353 lines

150

151 /* free the message */

152 SAFE_FREE(msg);

153 }

154

268 STAILQ_REMOVE_HEAD(&messages_queue, msg, next);

269 /* free the message */

270 SAFE_FREE(msg->message);

271 SAFE_FREE(msg);

297 STAILQ_REMOVE_HEAD(&messages_queue, msg, next);

298 /* free the message */

299 SAFE_FREE(msg->message);

300 SAFE_FREE(msg);

xalloc.h (https://github.com/dkurochkin/squid.git) C Header · 73 lines

61 * otherwise perror() is used to display it.

62 */

63 #define safe_free(x) while (x) { xxfree(x); (x) = NULL; }

64

65 #ifdef __cplusplus

utils_crypt.h (https://gitlab.com/omos/cryptsetup) C Header · 47 lines

38

39 void *crypt_safe_alloc(size_t size);

40 void crypt_safe_free(void *data);

41 void *crypt_safe_realloc(void *data, size_t size);

42

UrlPath.cc (https://github.com/hkerem/squid3-ssl.git) C++ · 58 lines

46 rfc1738_unescape(esc_buf);

47 int result = data->match(esc_buf);

48 safe_free(esc_buf);

49 return result;

50 }

vector_hash_map.c (https://github.com/SRI-CSL/yices2.git) C · 303 lines

132 for (i=0; i<n; i++) {

133 if (hmap->data[i] != NULL) {

134 safe_free(hmap->data[i]);

135 hmap->data[i] = NULL;

136 }

145 void delete_vector_hmap(vector_hmap_t *hmap) {

146 reset_vector_hmap(hmap);

147 safe_free(hmap->data);

148 hmap->data = NULL;

149 }

213 }

214

215 safe_free(hmap->data);

216 hmap->data = tmp;

217 hmap->size = new_size;

freeswitch_perl.cpp (https://github.com/curriegrad2004/FreeSWITCH.git) C++ · 286 lines

61 }

62

63 switch_safe_free(cb_function);

64 switch_safe_free(cb_arg);

65 switch_safe_free(hangup_func_str);

66 switch_safe_free(hangup_func_arg);

169 sanity_check_noreturn;

170

171 switch_safe_free(hangup_func_str);

172

173 if (func) {

185 {

186 sanity_check_noreturn;

187 switch_safe_free(cb_function);

188 switch_safe_free(cb_arg);

schema.c (https://github.com/vmware/lightwave.git) C · 161 lines

124

125 error:

126 VMDIR_SAFE_FREE_MEMORY(pszSchemaIdGuid);

127 return dwPriorResult ? dwPriorResult : dwRtn;

128 }

esl_oop.cpp (https://github.com/ppanhoto/Freeswitch-mod_mp4.git) C++ · 465 lines

310 me->event = NULL;

311 me->mine = 0;

312 esl_safe_free(me->serialized_string);

313 }

314

350 this_check("");

351

352 esl_safe_free(serialized_string);

353

354 if (format == NULL) {

nmbd_browserdb.c (https://github.com/rhuitl/uClinux.git) C · 176 lines

54 {

55 DLIST_REMOVE(lmb_browserlist, browc);

56 SAFE_FREE(browc);

57 }

58

ec_rlogin.c (git://pkgs.fedoraproject.org/ettercap) C · 197 lines

82 session_put(s);

83

84 SAFE_FREE(ident);

85 return NULL;

86 }

101 /* bad packet, abort the collection process */

102 session_del(ident, DISSECT_IDENT_LEN);

103 SAFE_FREE(ident);

104 return NULL;

105 }

106

107 SAFE_FREE(s->data);

108

109 /* make room for the string */

dbintegritychkjob.c (https://github.com/vmware/lightwave.git) C · 270 lines

64

65 cleanup:

66 VMDIR_SAFE_FREE_MEMORY(pszDBName);

67 VMDIR_UNLOCK_MUTEX(bInLock, gVmdirDBIntegrityCheck.pMutex);

68 return dwError;

253 if (pJob)

254 {

255 VMDIR_SAFE_FREE_MEMORY(pJob->pszDBName);

256

257 VmDirStringListFree(pJob->pAllDBNames);

260 for (dwJobCnt = 0; dwJobCnt < pJob->dwNumValidJobPerDB; dwJobCnt++)

261 {

262 VMDIR_SAFE_FREE_MEMORY(pJob->pJobPerDB[dwJobCnt].pszDBName);

263 }

264

dprintf.c (https://repo.or.cz/Samba/vfs_proxy.git) C · 118 lines

59 p2 = (char *)SMB_MALLOC(maxlen);

60 if (!p2) {

61 SAFE_FREE(p);

62 va_end(ap2);

63 return -1;

68 /* it didn't fit - try a larger buffer */

69 maxlen *= 2;

70 SAFE_FREE(p2);

71 goto again;

72 }

73

74 /* good, its converted OK */

75 SAFE_FREE(p);

76 ret = fwrite(p2, 1, clen, f);

77 SAFE_FREE(p2);

ec_streambuf.c (https://github.com/wertarbyte/ettercap.git) C · 261 lines

163

164 /* remove the entry from the tail */

165 SAFE_FREE(p->buf);

166 TAILQ_REMOVE(&sb->streambuf_tail, p, next);

167 SAFE_FREE(p);

245 while ((e = TAILQ_FIRST(&sb->streambuf_tail)) != TAILQ_END(&sb->streambuf_tail)) {

246 TAILQ_REMOVE(&sb->streambuf_tail, e, next);

247 SAFE_FREE(e->buf);

248 SAFE_FREE(e);

mod_mongo.cpp (https://github.com/tzuryby/mod_conference-admin.git) C++ · 225 lines

66 }

67

68 switch_safe_free(ns);

69

70 return status;

115 }

116

117 switch_safe_free(ns);

118

119 return status;

204 {

205 mongo_connection_pool_destroy(&globals.conn_pool);

206 switch_safe_free(globals.map);

207 switch_safe_free(globals.reduce);

208 switch_safe_free(globals.finalize);

209

210 return SWITCH_STATUS_SUCCESS;

settings.h (https://gitlab.com/adam.lukaitis/rufus) C Header · 136 lines

50 char* str = get_token_data_file(key, ini_file);

51 BOOL ret = (str != NULL);

52 safe_free(str);

53 return ret;

54 }

Macro.h (https://github.com/hyzboy/CMGameEngine.git) C Header · 119 lines

55 }

56

57 #define SAFE_FREE_OBJECT_ARRAY(name,num) { \

58 if(name) \

59 FREE_OBJECT_ARRAY(name,num); \

60 }

61

62 #define SAFE_FREE(name) { \

63 if(name) \

64 hgl_free(name); \

gpo_filesync.c (https://github.com/theuni/XBMC-deps.git) C · 241 lines

83

84 out:

85 SAFE_FREE(data);

86 if (fnum) {

87 smbcli_close(cli->tree, fnum);

winbind_nss_netbsd.c (https://gitlab.com/miztake/samba) C · 405 lines

215 (*groupc)++;

216 }

217 SAFE_FREE(wblistv);

218 return NS_NOTFOUND;

219 }

FilledChecklist.cc (git://pkgs.fedoraproject.org/squid) C++ · 216 lines

87 assert (!asyncInProgress());

88

89 safe_free(dst_rdns); // created by xstrdup().

90

91 if (extacl_entry)

changrid.c (https://gitlab.com/vmakarov/ml-gcc) C · 171 lines

163 }

164 for( channel = 1 ; channel <= numChans ; channel++ ) {

165 safe_free( gdptr[ channel ] ) ;

166 }

167 safe_free( gdptr ) ;

tsip_api_subscribe.c (https://gitlab.com/iwan.aucamp/doubango) C · 160 lines

80

81 tsk_object_unref(dialog);

82 TSK_OBJECT_SAFE_FREE(action);

83 }

84 va_end(ap);

108 if((action = _tsip_action_create(tsip_atype_unsubscribe, &ap))){

109 ret = tsip_ssession_handle(ss, action);

110 TSK_OBJECT_SAFE_FREE(action);

111 }

112 va_end(ap);

uint_rbtrees.c (https://github.com/SRI-CSL/yices2.git) C · 439 lines

98 */

99 void delete_rbtree(rbtree_t *tree) {

100 safe_free(tree->data);

101 safe_free(tree->node);

kdcreq.c (https://github.com/vmware/lightwave.git) C · 263 lines

22 {

23 if (pKdcReq) {

24 VMKDC_SAFE_FREE_METHOD_DATA(pKdcReq->padata);

25 VMKDC_SAFE_FREE_DATA(pKdcReq->req_body.realm);

26 VMKDC_SAFE_FREE_PRINCIPAL(pKdcReq->req_body.cname);

27 VMKDC_SAFE_FREE_PRINCIPAL(pKdcReq->req_body.sname);

28 VMKDC_SAFE_FREE_MEMORY(pKdcReq->req_body.etype.type);

29 VMKDC_SAFE_FREE_MEMORY(pKdcReq->req_body.from);

30 VMKDC_SAFE_FREE_MEMORY(pKdcReq->req_body.till);

31 VMKDC_SAFE_FREE_MEMORY(pKdcReq->req_body.rtime);

32 VMKDC_SAFE_FREE_MEMORY(pKdcReq);

33 }

34 }

nmbd_browserdb.c (https://gitlab.com/miztake/samba) C · 180 lines

55 {

56 DLIST_REMOVE(lmb_browserlist, browc);

57 SAFE_FREE(browc);

58 }

59

112 unstrcpy( browc->work_group, work_name);

113 if (!strupper_m( browc->lmb_name )) {

114 SAFE_FREE(browc);

115 return NULL;

116 }

117 if (!strupper_m( browc->work_group )) {

118 SAFE_FREE(browc);

119 return NULL;

120 }

TestList.c (https://github.com/alexdarling/roadrunner.git) C · 435 lines

369 fail_unless(List_size(L) == 3);

370

371 List_freeItems(L, safe_free, void);

372

373 fail_unless(List_size(L) == 0);

samba-sambagroups.patch (https://github.com/tenchman/TTLinux.git) Patch · 168 lines

120 + for (i = 0; i < response.data.num_entries; i++)

121 + if (gid == (int)((gid_t *)response.extra_data.data)[i]) {

122 + SAFE_FREE(response.extra_data.data);

123 + return 0;

124 + }

125 +

126 +

127 + SAFE_FREE(response.extra_data.data);

128 + return -1;

129 +}

ptr_sets.h (https://github.com/SRI-CSL/yices2.git) C Header · 166 lines

85 */

86 static inline void free_ptr_set(ptr_set_t *s) {

87 safe_free(s);

88 }

89

ftdm_buffer.c (https://github.com/curriegrad2004/FreeSWITCH.git) C · 302 lines

61 new_buffer->data = ftdm_malloc(start_len);

62 if (!new_buffer->data) {

63 ftdm_safe_free(new_buffer);

64 return FTDM_MEMERR;

65 }

284 {

285 if (*buffer) {

286 ftdm_safe_free((*buffer)->data);

287 ftdm_safe_free(*buffer);

test_uint8_arrays.c (https://github.com/SRI-CSL/yices2.git) C · 365 lines

87

88 for (i=0; i<n; i++) {

89 safe_free(array[i]);

90 }

91 }

263 abort();

264 }

265 safe_free(check);

266

267 uint8_array_push(b);

289 abort();

290 }

291 safe_free(check);

292 }

293