Don't use ami_NewMinList as it potentially writes past the MinList structure on OS3.

Instead we use ami_AllocMinList and pointers.
This commit is contained in:
Chris Young 2016-01-26 19:40:59 +00:00
parent 520e81f98d
commit 04cbc08c57
3 changed files with 12 additions and 10 deletions

View File

@ -38,7 +38,7 @@
struct Library *OpenURLBase = NULL; struct Library *OpenURLBase = NULL;
struct OpenURLIFace *IOpenURL = NULL; struct OpenURLIFace *IOpenURL = NULL;
struct MinList ami_unsupportedprotocols; struct MinList *ami_unsupportedprotocols;
struct ami_protocol struct ami_protocol
{ {
@ -65,7 +65,7 @@ static struct ami_protocol *ami_openurl_add_protocol(const char *url)
return NULL; return NULL;
} }
AddTail((struct List *)&ami_unsupportedprotocols, (struct Node *)ami_p); AddTail((struct List *)ami_unsupportedprotocols, (struct Node *)ami_p);
return ami_p; return ami_p;
} }
@ -86,6 +86,8 @@ static void ami_openurl_free_list(struct MinList *list)
FreeVec(node); FreeVec(node);
node = NULL; node = NULL;
}while((node=nnode)); }while((node=nnode));
FreeVec(list);
} }
static BOOL ami_openurl_check_list(struct MinList *list, nsurl *url) static BOOL ami_openurl_check_list(struct MinList *list, nsurl *url)
@ -132,7 +134,7 @@ void ami_openurl_open(void)
} }
} }
ami_NewMinList(&ami_unsupportedprotocols); ami_unsupportedprotocols = ami_AllocMinList();
} }
void ami_openurl_close(void) void ami_openurl_close(void)
@ -142,7 +144,7 @@ void ami_openurl_close(void)
#endif #endif
if(OpenURLBase) CloseLibrary(OpenURLBase); if(OpenURLBase) CloseLibrary(OpenURLBase);
ami_openurl_free_list(&ami_unsupportedprotocols); ami_openurl_free_list(ami_unsupportedprotocols);
} }
nserror gui_launch_url(struct nsurl *url) nserror gui_launch_url(struct nsurl *url)
@ -152,7 +154,7 @@ nserror gui_launch_url(struct nsurl *url)
#endif #endif
char *launchurl = NULL; char *launchurl = NULL;
if(ami_openurl_check_list(&ami_unsupportedprotocols, url) == FALSE) if(ami_openurl_check_list(ami_unsupportedprotocols, url) == FALSE)
{ {
if(IOpenURL) if(IOpenURL)
{ {

View File

@ -57,7 +57,6 @@ void FreeObjList(struct MinList *objlist);
/** List abstraction as OS3 appears to have problems with NewMinList() **/ /** List abstraction as OS3 appears to have problems with NewMinList() **/
struct MinList *ami_AllocMinList(void); struct MinList *ami_AllocMinList(void);
void ami_NewMinList(struct MinList *list);
/** Initialisation for itempool **/ /** Initialisation for itempool **/
bool ami_object_init(void); bool ami_object_init(void);

View File

@ -109,7 +109,7 @@ struct treeview_window {
char *sslerr; char *sslerr;
char *sslaccept; char *sslaccept;
char *sslreject; char *sslreject;
struct MinList shared_pens; struct MinList *shared_pens;
}; };
struct ami_tree_redraw_req { struct ami_tree_redraw_req {
@ -887,7 +887,8 @@ void ami_tree_close(struct treeview_window *twin)
DisposeObject(twin->objects[OID_MAIN]); DisposeObject(twin->objects[OID_MAIN]);
DelObjectNoFree(twin->node); DelObjectNoFree(twin->node);
ami_free_layers(&twin->globals); ami_free_layers(&twin->globals);
ami_plot_release_pens(&twin->shared_pens); ami_plot_release_pens(twin->shared_pens);
FreeVec(twin->shared_pens);
for(i=0;i<AMI_TREE_MENU_ITEMS;i++) { for(i=0;i<AMI_TREE_MENU_ITEMS;i++) {
if(twin->menu_name[i] && (twin->menu_name[i] != NM_BARLABEL)) if(twin->menu_name[i] && (twin->menu_name[i] != NM_BARLABEL))
@ -1485,8 +1486,8 @@ struct treeview_window *ami_tree_create(int flags,
twin->ssl_data = ssl_data; twin->ssl_data = ssl_data;
twin->tree = tree_create(flags, &ami_tree_callbacks, twin); twin->tree = tree_create(flags, &ami_tree_callbacks, twin);
ami_NewMinList(&twin->shared_pens); twin->shared_pens = ami_AllocMinList();
twin->globals.shared_pens = &twin->shared_pens; twin->globals.shared_pens = twin->shared_pens;
return twin; return twin;
} }