You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/* point 5, in section "Retrieving Data with SQLGetData" in http://msdn.microsoft.com/en-us/library/windows/desktop/ms715441(v=vs.85).aspx
658
+
states that if SQL_SUCCESS_WITH_INFO, fetched_len will be > 255 (greater than buf2's size)
659
+
(if a driver fails to follow that and wrote less than 255 bytes to buf2, this will AV or read garbage into buf) */
660
+
buf=erealloc(buf, used+255+1);
661
+
memcpy(buf+used, buf2, 255);
662
+
used=used+255;
663
+
} elseif (rc==SQL_SUCCESS) {
664
+
buf=erealloc(buf, used+C->fetched_len+1);
665
+
memcpy(buf+used, buf2, C->fetched_len);
666
+
used=used+C->fetched_len;
667
667
} else {
668
-
used+=C->fetched_len;
669
-
}
670
-
671
-
if (rc==SQL_SUCCESS) {
672
-
/* this was the final fetch */
668
+
/* includes SQL_NO_DATA */
673
669
break;
674
670
}
675
-
676
-
/* we need to fetch another chunk; resize the
677
-
* buffer */
678
-
alloced *= 2;
679
-
buf=erealloc(buf, alloced);
671
+
680
672
} while (1);
681
-
682
-
/* size down */
683
-
if (used<alloced-1024) {
684
-
alloced=used+1;
685
-
buf=erealloc(buf, used+1);
686
-
}
673
+
674
+
efree(buf2);
675
+
676
+
/* NULL terminate the buffer once, when finished, for use with the rest of PHP */
0 commit comments