projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix crash when parsing a badly formatted variable string.
[pspp]
/
src
/
libpspp
/
sparse-array.c
diff --git
a/src/libpspp/sparse-array.c
b/src/libpspp/sparse-array.c
index 28398d5cc86321e9e648a9c0ac30c052c1d26641..65a4612259f7e0510feb8cb55bbd7e619ce3e1d5 100644
(file)
--- a/
src/libpspp/sparse-array.c
+++ b/
src/libpspp/sparse-array.c
@@
-1,5
+1,5
@@
/* PSPP - a program for statistical analysis.
/* PSPP - a program for statistical analysis.
- Copyright (C) 2007, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009
, 2010, 2011
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@
-16,17
+16,18
@@
#include <config.h>
#include <config.h>
-#include
<libpspp/sparse-array.h>
+#include
"libpspp/sparse-array.h"
#include <limits.h>
#include <string.h>
#include <limits.h>
#include <string.h>
-#include <libpspp/assertion.h>
-#include <libpspp/misc.h>
-#include <libpspp/pool.h>
+#include "libpspp/assertion.h"
+#include "libpspp/cast.h"
+#include "libpspp/misc.h"
+#include "libpspp/pool.h"
-#include "count-one-bits.h"
-#include "minmax.h"
+#include "
gl/
count-one-bits.h"
+#include "
gl/
minmax.h"
/* Sparse array data structure.
/* Sparse array data structure.
@@
-533,7
+534,9
@@
scan_in_use_reverse (struct leaf_node *leaf, unsigned int idx)
for (;;)
{
int ofs = idx % LONG_BITS;
for (;;)
{
int ofs = idx % LONG_BITS;
- unsigned long int in_use = leaf->in_use[idx / LONG_BITS] << (31 - ofs);
+ unsigned long int in_use;
+
+ in_use = leaf->in_use[idx / LONG_BITS] << (LONG_BITS - 1 - ofs);
if (in_use)
return idx - count_leading_zeros (in_use);
if (idx < LONG_BITS)
if (in_use)
return idx - count_leading_zeros (in_use);
if (idx < LONG_BITS)
@@
-577,7
+580,7
@@
leaf_size (const struct sparse_array *spar)
static struct leaf_node *
find_leaf_node (const struct sparse_array *spar_, unsigned long int key)
{
static struct leaf_node *
find_leaf_node (const struct sparse_array *spar_, unsigned long int key)
{
- struct sparse_array *spar =
(struct sparse_array *) spar_
;
+ struct sparse_array *spar =
CONST_CAST (struct sparse_array *, spar_)
;
const union pointer *p;
int level;
const union pointer *p;
int level;
@@
-679,7
+682,7
@@
static void *
scan_forward (const struct sparse_array *spar_, unsigned long int start,
unsigned long int *found)
{
scan_forward (const struct sparse_array *spar_, unsigned long int start,
unsigned long int *found)
{
- struct sparse_array *spar =
(struct sparse_array *) spar_
;
+ struct sparse_array *spar =
CONST_CAST (struct sparse_array *, spar_)
;
/* Check the cache. */
if (start >> BITS_PER_LEVEL == spar->cache_ofs)
/* Check the cache. */
if (start >> BITS_PER_LEVEL == spar->cache_ofs)
@@
-761,7
+764,7
@@
static void *
scan_reverse (const struct sparse_array *spar_, unsigned long int start,
unsigned long int *found)
{
scan_reverse (const struct sparse_array *spar_, unsigned long int start,
unsigned long int *found)
{
- struct sparse_array *spar =
(struct sparse_array *) spar_
;
+ struct sparse_array *spar =
CONST_CAST (struct sparse_array *, spar_)
;
/* Check the cache. */
if (start >> BITS_PER_LEVEL == spar->cache_ofs)
/* Check the cache. */
if (start >> BITS_PER_LEVEL == spar->cache_ofs)