Skip to content

Commit 4bccb45

Browse files
committed
MFH: const pointer was used in non-const context
1 parent e45c0bb commit 4bccb45

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

ext/pdo_sqlite/sqlite_statement.c

+12-4
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,8 @@ static int pdo_sqlite_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsi
282282
static int pdo_sqlite_stmt_col_meta(pdo_stmt_t *stmt, long colno, zval *return_value TSRMLS_DC)
283283
{
284284
pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data;
285+
const char *_str;
286+
size_t _str_len;
285287
char *str;
286288
zval *flags;
287289

@@ -318,14 +320,20 @@ static int pdo_sqlite_stmt_col_meta(pdo_stmt_t *stmt, long colno, zval *return_v
318320
break;
319321
}
320322

321-
str = (char*)sqlite3_column_decltype(S->stmt, colno);
322-
if (str) {
323+
_str = sqlite3_column_decltype(S->stmt, colno);
324+
_str_len = strlen(_str);
325+
if (_str) {
326+
str = emalloc(_str_len);
327+
strcpy(str, _str);
323328
add_assoc_string(return_value, "sqlite:decl_type", str, 1);
324329
}
325330

326331
#ifdef SQLITE_ENABLE_COLUMN_METADATA
327-
str = sqlite3_column_table_name(S->stmt, colno);
328-
if (str) {
332+
_str = sqlite3_column_table_name(S->stmt, colno);
333+
_str_len = strlen(_str);
334+
if (_str) {
335+
str = emalloc(_str_len);
336+
strcpy(str, _str);
329337
add_assoc_string(return_value, "table", str, 1);
330338
}
331339
#endif

0 commit comments

Comments
 (0)