summaryrefslogtreecommitdiffstats
path: root/loader/module.c
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2010-03-09 23:03:14 +0200
committerUoti Urpala <uau@glyph.nonexistent.invalid>2010-03-09 23:03:14 +0200
commit36e7a20e695b376287310d602b44d6719f82a021 (patch)
tree75070d702043e875c947fccaa2de7a419331de22 /loader/module.c
parent70fb003a9f2d9dc764e320f3ca64b0af1c68fdfb (diff)
parent93abb4f09229730c30e5bbdd6c54d4b981995eee (diff)
downloadmpv-36e7a20e695b376287310d602b44d6719f82a021.tar.bz2
mpv-36e7a20e695b376287310d602b44d6719f82a021.tar.xz
Merge svn changes up to r30550
Diffstat (limited to 'loader/module.c')
-rw-r--r--loader/module.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/loader/module.c b/loader/module.c
index 2bce928544..feaab14605 100644
--- a/loader/module.c
+++ b/loader/module.c
@@ -744,6 +744,31 @@ static int dump_component(char* name, int type, void* orig, ComponentParameters
#ifdef EMU_QTX_API
+#ifdef __OS2__
+uint32_t _System DosQueryMem(void *, uint32_t *, uint32_t *);
+#endif
+
+static int is_invalid_ptr_handle(void *p)
+{
+#ifdef __OS2__
+ uint32_t cb = 1;
+ uint32_t fl;
+
+ if(DosQueryMem(p, &cb, &fl))
+ return 1;
+
+ // Occasionally, ptr with 'EXEC' attr is passed.
+ // On OS/2, however, malloc() never sets 'EXEC' attr.
+ // So ptr with 'EXEC' attr is invalid.
+ if(fl & 0x04)
+ return 1;
+
+ return 0;
+#else
+ return (uint32_t)p >= 0x60000000;
+#endif
+}
+
static uint32_t ret_array[4096];
static int ret_i=0;
@@ -844,10 +869,10 @@ static int report_func(void *stack_base, int stack_size, reg386_t *reg, uint32_t
#endif
return 1;
case 0x15002f: //DisposePtr
- if(((uint32_t *)stack_base)[1]>=0x60000000)
+ if(is_invalid_ptr_handle(((void **)stack_base)[1]))
printf("WARNING! Invalid Ptr handle!\n");
else
- free((void *)((uint32_t *)stack_base)[1]);
+ free(((void **)stack_base)[1]);
reg->eax=0;
#ifdef DEBUG_QTX_API
printf("%*sLEAVE(%d): EMULATED! 0x%X\n",ret_i*2,"",ret_i, reg->eax);