Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit ee9fa77

Browse files
authored
Fix OSX segfault in extension (#133)
* All versions need php_rand include * Fix compiler warnings on OSX * Fix some warnings on OSX in debug mode * Fix double string release
1 parent 8c95afa commit ee9fa77

File tree

6 files changed

+10
-12
lines changed

6 files changed

+10
-12
lines changed

ext/opencensus_trace.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@
2828
#include "zend_extensions.h"
2929
#include "standard/php_math.h"
3030
#include "ext/standard/info.h"
31-
32-
#if PHP_VERSION_ID < 70100
3331
#include "standard/php_rand.h"
34-
#endif
3532

3633
/**
3734
* True globals for storing the original zend_execute_ex and
@@ -146,11 +143,12 @@ static zend_string *span_id_from_options(HashTable *options)
146143
return NULL;
147144
}
148145

149-
if (val = zend_hash_str_find(options, "spanId", strlen("spanId"))) {
150-
return Z_STR_P(val);
151-
} else {
146+
val = zend_hash_str_find(options, "spanId", strlen("spanId"));
147+
if (val == NULL) {
152148
return NULL;
153149
}
150+
151+
return Z_STR_P(val);
154152
}
155153

156154
static opencensus_trace_span_t *span_from_options(zval *options)
@@ -162,7 +160,8 @@ static opencensus_trace_span_t *span_from_options(zval *options)
162160
return NULL;
163161
}
164162

165-
if (span_id = span_id_from_options(Z_ARR_P(options))) {
163+
span_id = span_id_from_options(Z_ARR_P(options));
164+
if (span_id != NULL) {
166165
span = (opencensus_trace_span_t *)zend_hash_find_ptr(OPENCENSUS_TRACE_G(spans), span_id);
167166
}
168167

@@ -365,7 +364,6 @@ static void opencensus_trace_execute_callback(opencensus_trace_span_t *span, zen
365364
opencensus_trace_span_apply_span_options(span, &callback_result);
366365
}
367366
ZVAL_DESTRUCTOR(&callback_result);
368-
zend_string_release(callback_name);
369367
} else if (Z_TYPE_P(span_options) == IS_ARRAY) {
370368
opencensus_trace_span_apply_span_options(span, span_options);
371369
}

ext/opencensus_trace_annotation.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444

4545
#include "php_opencensus.h"
4646
#include "opencensus_trace_annotation.h"
47+
#include "Zend/zend_alloc.h"
4748

4849
zend_class_entry* opencensus_trace_annotation_ce = NULL;
4950

ext/opencensus_trace_link.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444

4545
#include "php_opencensus.h"
4646
#include "opencensus_trace_link.h"
47+
#include "Zend/zend_alloc.h"
4748

4849
zend_class_entry* opencensus_trace_link_ce = NULL;
4950

ext/opencensus_trace_message_event.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050

5151
#include "php_opencensus.h"
5252
#include "opencensus_trace_message_event.h"
53+
#include "Zend/zend_alloc.h"
5354

5455
zend_class_entry* opencensus_trace_message_event_ce = NULL;
5556

ext/opencensus_trace_span.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
#include "opencensus_trace_annotation.h"
9191
#include "opencensus_trace_link.h"
9292
#include "opencensus_trace_message_event.h"
93+
#include "Zend/zend_alloc.h"
9394

9495
zend_class_entry* opencensus_trace_span_ce = NULL;
9596

ext/php_opencensus.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@
3333
#define PHP_OPENCENSUS_VERSION "0.1.2"
3434
#define PHP_OPENCENSUS_EXTNAME "opencensus"
3535

36-
#define PHP_OPENCENSUS_MAKE_STD_ZVAL(pzv) \
37-
pzv = (zval *)emalloc(sizeof(zval));
38-
#define PHP_OPENCENSUS_FREE_STD_ZVAL(pzv) efree(pzv);
39-
4036
PHP_FUNCTION(opencensus_version);
4137

4238
extern zend_module_entry opencensus_module_entry;

0 commit comments

Comments
 (0)