Skip to content
Browse files

Resolved some memory leaks in mergJSONDecode

  • Loading branch information...
1 parent 2650cf4 commit e8fe3bcf2dedf634abe42ccf328af715ad30b014 @montegoulding committed Jul 4, 2014
View
4 mergJSON.xcodeproj/project.pbxproj
@@ -506,7 +506,7 @@
COMBINE_HIDPI_IMAGES = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "";
- GCC_VERSION = com.apple.compilers.llvmgcc42;
+ GCC_VERSION = "";
HEADER_SEARCH_PATHS = /Users/montegoulding/jansson/src;
INFOPLIST_FILE = "mergJSON/mergJSON-Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles";
@@ -527,7 +527,7 @@
COMBINE_HIDPI_IMAGES = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "";
- GCC_VERSION = com.apple.compilers.llvmgcc42;
+ GCC_VERSION = "";
HEADER_SEARCH_PATHS = /Users/montegoulding/jansson/src;
INFOPLIST_FILE = "mergJSON/mergJSON-Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles";
View
53 mergJSON.xcodeproj/project.xcworkspace/xcshareddata/mergJSON.xccheckout
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>IDESourceControlProjectFavoriteDictionaryKey</key>
+ <false/>
+ <key>IDESourceControlProjectIdentifier</key>
+ <string>17800481-11DC-4E51-922B-18D263946960</string>
+ <key>IDESourceControlProjectName</key>
+ <string>mergJSON</string>
+ <key>IDESourceControlProjectOriginsDictionary</key>
+ <dict>
+ <key>014050E5-A709-4D58-85E3-267DD8E1E643</key>
+ <string>https://github.com/montegoulding/mergJSON.git</string>
+ <key>BA42591C-736E-4E9D-BF4D-3D9D4672F0EE</key>
+ <string>git://github.com/akheron/jansson.git</string>
+ </dict>
+ <key>IDESourceControlProjectPath</key>
+ <string>mergJSON.xcodeproj/project.xcworkspace</string>
+ <key>IDESourceControlProjectRelativeInstallPathDictionary</key>
+ <dict>
+ <key>014050E5-A709-4D58-85E3-267DD8E1E643</key>
+ <string>../..</string>
+ <key>BA42591C-736E-4E9D-BF4D-3D9D4672F0EE</key>
+ <string>../../mergJSON/jansson</string>
+ </dict>
+ <key>IDESourceControlProjectURL</key>
+ <string>https://github.com/montegoulding/mergJSON.git</string>
+ <key>IDESourceControlProjectVersion</key>
+ <integer>110</integer>
+ <key>IDESourceControlProjectWCCIdentifier</key>
+ <string>014050E5-A709-4D58-85E3-267DD8E1E643</string>
+ <key>IDESourceControlProjectWCConfigurations</key>
+ <array>
+ <dict>
+ <key>IDESourceControlRepositoryExtensionIdentifierKey</key>
+ <string>public.vcs.git</string>
+ <key>IDESourceControlWCCIdentifierKey</key>
+ <string>BA42591C-736E-4E9D-BF4D-3D9D4672F0EE</string>
+ <key>IDESourceControlWCCName</key>
+ <string>jansson</string>
+ </dict>
+ <dict>
+ <key>IDESourceControlRepositoryExtensionIdentifierKey</key>
+ <string>public.vcs.git</string>
+ <key>IDESourceControlWCCIdentifierKey</key>
+ <string>014050E5-A709-4D58-85E3-267DD8E1E643</string>
+ <key>IDESourceControlWCCName</key>
+ <string>mergjson</string>
+ </dict>
+ </array>
+</dict>
+</plist>
View
11 mergJSON/mergJSON.c
@@ -47,15 +47,12 @@ char * getPrimitiveString(json_t * tJSON) {
switch (json_typeof(tJSON))
{
case JSON_TRUE:
- tReturn = (char*)malloc(5);
tReturn = strdup("true");
break;
case JSON_FALSE:
- tReturn = (char*)malloc(6);
tReturn = strdup("false");
break;
case JSON_NULL:
- tReturn = (char*)malloc(5);
tReturn = strdup("null");
break;
case JSON_INTEGER:
@@ -76,7 +73,7 @@ char * getPrimitiveString(json_t * tJSON) {
{
char * tTemp = (char *)json_string_value(tJSON);
tReturn = (char*)malloc(strlen(tTemp)+1);
- tReturn = strdup(tTemp);
+ snprintf(tReturn,strlen(tTemp),"%s",tTemp);
}
break;
case JSON_OBJECT:
@@ -354,13 +351,12 @@ LIVECODE_FUNCTION(mergJSONDecode)
}
tArray[i].buffer = tKeyJSON;
tArray[i].length = (int)strlen(tKeyJSON);
-
}
SetArray(p_arguments[1], tSize, tArray, NULL, &success);
if (success == EXTERNAL_FAILURE) {
LIVECODE_ERROR("could not set array");
}
- for (i=1;i<tSize;i++) {
+ for (i=0;i<tSize;i++) {
free((void *)tArray[i].buffer);
}
@@ -400,8 +396,9 @@ LIVECODE_FUNCTION(mergJSONDecode)
LIVECODE_ERROR("could not set array");
}
- for (i=1;i<tSize;i++) {
+ for (i=0;i<tSize;i++) {
free((void *)tArray[i].buffer);
+ free(tKeys[i]);
}
}
View
3 mergJSON/mergJSON.livecode.vcs/5C/3ECC1C-2788-498D-A1CC-062FB0D91CF5/layers
@@ -5,5 +5,4 @@ C305E415-4BE6-45F8-92E1-A861550D7844
FA87FEC5-6A35-4B24-8BA0-92D974F5132E
FF98D9BE-39AF-44EC-9F61-A9A945414049
10d4502c-0466-4e65-a0d4-f7d033ccaef5
-8653e971-ee37-43be-9e72-690895dc37a9
-9f58b393-ad3c-4de9-876b-97f8dffde4c7
+eb0a6f8e-1ad5-4cd7-8cfe-f35aabbf5649
View
11 mergJSON/mergJSON.livecode.vcs/86/53e971-ee37-43be-9e72-690895dc37a9/script.utf8
@@ -1,11 +0,0 @@
-on mouseUp
- try
- accept connections on port 8009 with message "helloWorld"
- catch e
- answer e
- end try
-end mouseUp
-
-on helloWorld pID
- answer "hi"&&pID
-end helloWorld
View
91 mergJSON/mergJSON.livecode.vcs/9f/58b393-ad3c-4de9-876b-97f8dffde4c7/properties.json
@@ -1,91 +0,0 @@
-{
- "UUID": "9f58b393-ad3c-4de9-876b-97f8dffde4c7",
- "class": "com.runrev.engine.button",
- "customPropertySets": {
- "cREVGeneral": {
- "revUniqueID": "1371292829924"
- }
- },
- "properties": {
- "accelKey": "",
- "accelMods": "",
- "accelText": "",
- "altId": "0",
- "armBorder": "true",
- "armFill": "false",
- "armedIcon": "0",
- "autoArm": "false",
- "autoHilite": "true",
- "backColor": "",
- "backPattern": "",
- "behavior": "",
- "blendLevel": "0",
- "borderColor": "",
- "borderPattern": "",
- "borderWidth": "2",
- "bottomColor": "",
- "bottomPattern": "",
- "cantSelect": "false",
- "colorOverlay": "",
- "default": "false",
- "disabled": "false",
- "disabledIcon": "0",
- "dropShadow": "",
- "family": "0",
- "focusColor": "",
- "focusPattern": "",
- "foreColor": "",
- "forePattern": "",
- "hiliteBorder": "true",
- "hiliteColor": "",
- "hiliteFill": "true",
- "hiliteIcon": "0",
- "hilitePattern": "",
- "hilited": "false",
- "hoverIcon": "0",
- "icon": "0",
- "id": "1017",
- "ink": "srcCopy",
- "innerGlow": "",
- "innerShadow": "",
- "label": "",
- "labelWidth": "0",
- "layerMode": "static",
- "lockLoc": "false",
- "margins": "4",
- "menuHistory": "1",
- "menuLines": "5",
- "menuMode": "",
- "menuMouseButton": "1",
- "menuName": "",
- "mnemonic": "0",
- "name": "Button",
- "opaque": "true",
- "outerGlow": "",
- "rect": "236,52,318,75",
- "shadow": "false",
- "shadowColor": "",
- "shadowOffset": "4",
- "shadowPattern": "",
- "sharedHilite": "true",
- "showBorder": "true",
- "showFocusBorder": "true",
- "showHilite": "false",
- "showIcon": "false",
- "showName": "true",
- "style": "standard",
- "text": "",
- "textAlign": "center",
- "textFont": "",
- "textSize": "",
- "textStyle": "",
- "threeD": "true",
- "titleWidth": "0",
- "toolTip": "",
- "topColor": "",
- "topPattern": "",
- "traversalOn": "false",
- "visible": "true",
- "visitedIcon": "0"
- }
-}
View
7 mergJSON/mergJSON.livecode.vcs/9f/58b393-ad3c-4de9-876b-97f8dffde4c7/script.utf8
@@ -1,7 +0,0 @@
-on mouseUp
- open socket to "192.168.2.6:8009" with message "hi"
-end mouseUp
-
-on hi pID
- answer pID
-end hi
View
5 mergJSON/mergJSON.livecode.vcs/F5/3B34CA-2443-4E91-8AD1-492336C3F706/properties.json
@@ -2,6 +2,9 @@
"UUID": "F53B34CA-2443-4E91-8AD1-492336C3F706",
"class": "com.runrev.engine.stack",
"customPropertySets": {
+ "cREVGeneral": {
+ "scalefactor": "1"
+ },
"cRevStandaloneSettings": {
"CopyReferencedFiles": "false",
"Linux": "false",
@@ -67,7 +70,7 @@
"cantAbort": "false",
"cantDelete": "false",
"cantModify": "false",
- "decorations": "default",
+ "decorations": "title,menu,minimize,maximize,close",
"destroyStack": "false",
"destroyWindow": "false",
"dynamicPaths": "false",
View
2 mergJSON/mergJSON.livecode.vcs/F5/3B34CA-2443-4E91-8AD1-492336C3F706/userstate.json
@@ -1,6 +1,6 @@
{
"cRevStandaloneSettings": {
"automaticallyBuildInDefaultFolder": "",
- "defaultBuildFolder": "/Users/montegoulding/Desktop"
+ "defaultBuildFolder": ""
}
}
View
8 ...37-43be-9e72-690895dc37a9/properties.json → ...d5-4cd7-8cfe-f35aabbf5649/properties.json
@@ -1,9 +1,9 @@
{
- "UUID": "8653e971-ee37-43be-9e72-690895dc37a9",
+ "UUID": "eb0a6f8e-1ad5-4cd7-8cfe-f35aabbf5649",
"class": "com.runrev.engine.button",
"customPropertySets": {
"cREVGeneral": {
- "revUniqueID": "1371292561880"
+ "revUniqueID": "1404443101887"
}
},
"properties": {
@@ -44,7 +44,7 @@
"hilited": "false",
"hoverIcon": "0",
"icon": "0",
- "id": "1015",
+ "id": "1019",
"ink": "srcCopy",
"innerGlow": "",
"innerShadow": "",
@@ -62,7 +62,7 @@
"name": "Button",
"opaque": "true",
"outerGlow": "",
- "rect": "136,42,218,65",
+ "rect": "40,78,122,101",
"shadow": "false",
"shadowColor": "",
"shadowOffset": "4",
View
3 mergJSON/mergJSON.livecode.vcs/eb/0a6f8e-1ad5-4cd7-8cfe-f35aabbf5649/script.utf8
@@ -0,0 +1,3 @@
+on mouseUp
+ put JSONToArray(format("{ \"hello\" : \"world\"}"))
+end mouseUp

0 comments on commit e8fe3bc

Please sign in to comment.
Something went wrong with that request. Please try again.