From f9e90d90fa7cbf21752b06649af7bcf818518b86 Mon Sep 17 00:00:00 2001 From: whitequark Date: Thu, 31 Dec 2015 21:16:18 +0800 Subject: [PATCH] runtime/artiq_personality.c: don't dereference nonexistent typeInfoPtr. --- artiq/runtime/artiq_personality.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/artiq/runtime/artiq_personality.c b/artiq/runtime/artiq_personality.c index 664f43a1f..00e322434 100644 --- a/artiq/runtime/artiq_personality.c +++ b/artiq/runtime/artiq_personality.c @@ -415,17 +415,19 @@ _Unwind_Reason_Code __artiq_personality( (void*)typeInfoOffset, (void*)actionOffset); EH_ASSERT((typeInfoOffset >= 0) && "Filter clauses are not supported"); - unsigned encodingSize = getEncodingSize(ttypeEncoding); - const uint8_t *typeInfoPtrPtr = classInfo - typeInfoOffset * encodingSize; - uintptr_t typeInfoPtr = readEncodedPointer(&typeInfoPtrPtr, ttypeEncoding); - EH_LOG("encodingSize=%u typeInfoPtrPtr=%p typeInfoPtr=%p", - encodingSize, typeInfoPtrPtr, (void*)typeInfoPtr); - EH_LOG("typeInfo=%s", (char*)typeInfoPtr); + if(typeInfoOffset > 0) { + unsigned encodingSize = getEncodingSize(ttypeEncoding); + const uint8_t *typeInfoPtrPtr = classInfo - typeInfoOffset * encodingSize; + uintptr_t typeInfoPtr = readEncodedPointer(&typeInfoPtrPtr, ttypeEncoding); + EH_LOG("encodingSize=%u typeInfoPtrPtr=%p typeInfoPtr=%p", + encodingSize, typeInfoPtrPtr, (void*)typeInfoPtr); + EH_LOG("typeInfo=%s", (char*)typeInfoPtr); - if(typeInfoPtr == 0 || !strcmp(inflight->artiq.typeinfo, typeInfoPtr)) { - EH_LOG0("matching action found"); - exceptionMatched = 1; - break; + if(typeInfoPtr == 0 || !strcmp(inflight->artiq.typeinfo, typeInfoPtr)) { + EH_LOG0("matching action found"); + exceptionMatched = 1; + break; + } } if (!actionOffset)